add describe function

This commit is contained in:
tristan 2024-01-02 13:15:50 +00:00
parent 0b7f5ad721
commit 0dd646775e
7 changed files with 80 additions and 37 deletions

21
test/describe.test.nix Normal file
View file

@ -0,0 +1,21 @@
{
describe,
it,
...
}:
describe "the describe function" [
(it "returns an array with the message changed" {
expected = [
{
success = true;
msg = "the describe function: works";
}
];
actual = describe "the describe function" [
{
success = true;
msg = "works";
}
];
})
]

View file

@ -1,11 +1,17 @@
{ it, ... }:
[
{
it,
describe,
...
}:
describe "it" [
(it "test's itself???" rec {
expected = {success = true; msg = "test's itself???";};
actual =
(it "test's itself???" {
expected = expected;
actual = expected;
});
expected = {
success = true;
msg = "test's itself???";
};
actual = it "test's itself???" {
expected = expected;
actual = expected;
};
})
]

View file

@ -1,10 +1,8 @@
{ it, ... }:
let
{it, ...}: let
pkgs = import <nixpkgs> {}; # impure ¯\_(ツ)_/¯
run = import ../tix/run.nix pkgs;
output = run [ ./it.test.nix ];
in
[
output = run [./it.test.nix];
in [
(it "makes a derivation called test" {
expected = "test";
actual = output.name;

View file

@ -1,18 +1,26 @@
{ it, ... }:
let
{
describe,
it,
...
}: let
test = import ../tix/test.nix;
in
[
(it "get's test results" {
expected = [{"msg" = "test's itself???"; "success"= true;}];
actual = ( test ./it.test.nix ).results;
})
(it "has a path" {
actual = builtins.typeOf ( test ./it.test.nix ).path;
expected = "path";
})
(it "fails to build non test" {
actual = ( test ./bad/string.nix );
throws = true;
})
]
describe "the test function" [
(it "get's test results" {
expected = [
{
"msg" = "it: test's itself???";
"success" = true;
}
];
actual = (test ./it.test.nix).results;
})
(it "has a path" {
actual = builtins.typeOf (test ./it.test.nix).path;
expected = "path";
})
(it "fails to build non test" {
actual = test ./bad/string.nix;
throws = true;
})
]