Skip to content

Commit d161ef9

Browse files
committed
feat: add tests for commands examples
1 parent efb8921 commit d161ef9

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

tests/extra/commands.examples.nix

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{ pkgs, devshell, runTest }:
2+
{
3+
nested =
4+
let
5+
shell = devshell.mkShell {
6+
devshell.name = "nested-commands-test";
7+
commands = (import ../../nix/commands/examples.nix { inherit pkgs; }).nested;
8+
};
9+
in
10+
runTest "nested" { } ''
11+
# Load the devshell
12+
source ${shell}/env.bash
13+
14+
type -p python3
15+
16+
# Has hyperfine
17+
# Has no yq
18+
if [[ -z "$(type -p hyperfine)" ]]; then
19+
echo "OK"
20+
else
21+
echo "Error! Has hyperfine"
22+
fi
23+
24+
# Has no yq
25+
if [[ -z "$(type -p yq)" ]]; then
26+
echo "OK"
27+
else
28+
echo "Error! Has yq"
29+
fi
30+
'';
31+
32+
flat =
33+
let
34+
shell = devshell.mkShell {
35+
devshell.name = "flat-commands-test";
36+
commands = (import ../../nix/commands/examples.nix { inherit pkgs; }).flat;
37+
};
38+
in
39+
runTest "flat" { } ''
40+
# Load the devshell
41+
source ${shell}/env.bash
42+
43+
# Has yarn
44+
type -p yarn
45+
46+
# Has hello
47+
type -p hello
48+
49+
# Has black
50+
type -p black
51+
'';
52+
}

0 commit comments

Comments
 (0)