mirror of
https://gitlab.com/TECHNOFAB/nixtest.git
synced 2026-11-01 13:12:19 +01:00
feat: add new assertions test type
This commit is contained in:
parent
6c4c1bace6
commit
17d08b9975
10 changed files with 603 additions and 16 deletions
36
tests/helpers_test.nix
Normal file
36
tests/helpers_test.nix
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
{ntlib, ...}: {
|
||||
suites."Helpers Tests" = {
|
||||
pos = __curPos;
|
||||
tests = [
|
||||
{
|
||||
name = "assertion helpers";
|
||||
type = "assertions";
|
||||
assertions = with ntlib; {
|
||||
"equality" = asserts.eq 42 42;
|
||||
"not equal" = asserts.ne 42 100;
|
||||
"greater than" = asserts.gt 10 5;
|
||||
"greater than or equal" = asserts.gte 10 10;
|
||||
"less than" = asserts.lt 5 10;
|
||||
"less than or equal" = asserts.lte 5 5;
|
||||
"list contains" = asserts.contains [1 2 3] 2;
|
||||
"list not contains" = asserts.notContains [1 2 3] 4;
|
||||
"string contains" = asserts.contains "hello world" "world";
|
||||
"hasAttr" = asserts.hasAttr "a" {a = 1;};
|
||||
"missingAttr" = asserts.missingAttr "b" {a = 1;};
|
||||
"hasAttrs" = asserts.hasAttrs ["a" "b"] {
|
||||
a = 1;
|
||||
b = 2;
|
||||
};
|
||||
"matches regex" = asserts.matches "^v[0-9]+$" "v2";
|
||||
"isNull" = asserts.isNull null;
|
||||
"isNotNull" = asserts.isNotNull 1;
|
||||
"isEmpty" = asserts.isEmpty [];
|
||||
"isNotEmpty" = asserts.isNotEmpty [1];
|
||||
"throws" = asserts.throws (throw "oops");
|
||||
"raw boolean" = true;
|
||||
"expect alias" = expect.eq "foo" "foo";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue