forked from fediversity/fediversity
parent
18bc596e76
commit
ef5202d8a8
2 changed files with 95 additions and 0 deletions
|
|
@ -14,6 +14,12 @@ concurrency:
|
|||
group: ${{ forgejo.workflow }}-${{ forgejo.event.pull_request.number || forgejo.ref }}
|
||||
|
||||
jobs:
|
||||
check-utils:
|
||||
runs-on: native
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: nix-shell --run 'nix-unit ./deployment/utils-test.nix'
|
||||
|
||||
check-function:
|
||||
runs-on: native
|
||||
steps:
|
||||
|
|
|
|||
89
deployment/utils-test.nix
Normal file
89
deployment/utils-test.nix
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
let
|
||||
inherit (import ../default.nix { }) pkgs;
|
||||
inherit (pkgs.callPackage ./utils.nix { })
|
||||
mapKeys
|
||||
evalOption
|
||||
toBash
|
||||
withPackages
|
||||
filterNull
|
||||
withEnv
|
||||
;
|
||||
inherit (pkgs) lib;
|
||||
inherit (lib) mkOption types;
|
||||
inherit (types) submodule;
|
||||
in
|
||||
{
|
||||
_class = "nix-unit";
|
||||
|
||||
test-mapKeys = {
|
||||
expr = mapKeys (k: "${k}${k}") { a = 1; };
|
||||
expected = {
|
||||
aa = 1;
|
||||
};
|
||||
};
|
||||
|
||||
test-evalOption = {
|
||||
expr = evalOption (mkOption {
|
||||
type = submodule {
|
||||
options = {
|
||||
a = mkOption { default = 3; };
|
||||
};
|
||||
};
|
||||
}) { };
|
||||
expected = {
|
||||
a = 3;
|
||||
};
|
||||
};
|
||||
|
||||
test-toBash-int = {
|
||||
expr = toBash 1;
|
||||
expected = "1";
|
||||
};
|
||||
|
||||
test-toBash-null = {
|
||||
expr = toBash null;
|
||||
expected = "";
|
||||
};
|
||||
|
||||
test-toBash-attrs = {
|
||||
expr = toBash { a = 1; };
|
||||
expected = ''{\"a\":1}'';
|
||||
};
|
||||
|
||||
test-toBash-str = {
|
||||
expr = toBash "'b\"";
|
||||
expected = "'b\\\"";
|
||||
};
|
||||
|
||||
test-withPackages = {
|
||||
expr = withPackages [ pkgs.hello ];
|
||||
expected = {
|
||||
makeWrapperArgs = [
|
||||
"--prefix"
|
||||
"PATH"
|
||||
":"
|
||||
"${lib.makeBinPath [ pkgs.hello ]}"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
test-filterNull = {
|
||||
expr = filterNull {
|
||||
a = 4;
|
||||
b = null;
|
||||
};
|
||||
expected = {
|
||||
a = 4;
|
||||
};
|
||||
};
|
||||
|
||||
test-withEnv = {
|
||||
expr = withEnv {
|
||||
a = 1;
|
||||
b = null;
|
||||
c = "'d\"";
|
||||
e.f = [ "g" ];
|
||||
};
|
||||
expected = ''a="1" b="" c="'d\"" e="{\"f\":[\"g\"]}"'';
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue