Skip to content

Commit 45c9ac7

Browse files
committed
Add unit tests for createNamespace
1 parent 89743ed commit 45c9ac7

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

tests/create-namespace.nix

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
lib,
3+
config,
4+
...
5+
}: let
6+
apps = config.applications;
7+
in {
8+
applications = {
9+
# Create an application with `createNamespace = true`
10+
test1.createNamespace = true;
11+
12+
# Create an application with `createNamespace = false`
13+
test2.createNamespace = false;
14+
};
15+
16+
test = {
17+
name = "create namespace";
18+
description = "Check that a namespace gets created when createNamespace is specified.";
19+
assertions = [
20+
{
21+
description = "A namespace resource should be created when `createNamespace = true`.";
22+
expression = apps.test1.resources.namespaces.test1;
23+
assertion = ns:
24+
ns.kind
25+
== "Namespace"
26+
&& ns.metadata.name == "test1";
27+
}
28+
29+
{
30+
description = "A namespace resource should not be created when `createNamespace = false`.";
31+
expression = apps.test2.resources.namespaces;
32+
assertion = nss: !(lib.hasAttr "test2" nss);
33+
}
34+
];
35+
};
36+
}

tests/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
./defaults.nix
77
./sync-options.nix
88
./compare-options.nix
9+
./create-namespace.nix
910
];
1011
};
1112
}

0 commit comments

Comments
 (0)