-
Notifications
You must be signed in to change notification settings - Fork 3
/
extra-module-tests.nu
59 lines (53 loc) · 1.16 KB
/
extra-module-tests.nu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use std assert
# TODO use testing.nu testing module,
# which wasn't working at the time I wrote these tests
#[test]
def test_shell_variables [] {
let actual = (echo "A=123" | bash-env -s).shellvars
let expected = { A: "123" }
assert equal $actual $expected
}
#[test]
def test_shell_variables_from_file [] {
let actual = bash-env -s tests/shell-variables.env
let expected = { shellvars: { A: "not exported" } env: { B: "exported" } }
assert equal $actual $expected
}
#[test]
def test_shell_functions [] {
let actual = bash-env -f [f2 f3] tests/shell-functions.env
let expected = {
"env": {
"B": "1",
"A": "1"
},
"shellvars": {},
"fn": {
"f2": {
"env": {
"B": "2",
"A": "2"
},
"shellvars": {
"C2": "I am shell variable C2"
}
},
"f3": {
"env": {
"B": "3",
"A": "3"
},
"shellvars": {
"C3": "I am shell variable C3"
}
}
}
}
assert equal $actual $expected
}
export def main [] {
test_shell_variables
test_shell_variables_from_file
test_shell_functions
print "All tests passed"
}