-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
36aaab3
commit 38761ef
Showing
8 changed files
with
112 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
use std assert | ||
|
||
# TODO use testing.nu testing module, | ||
# which wasn't working at the time I wrote these tests | ||
|
||
#[before-all] | ||
def add_and_use_plugin [] { | ||
plugin add nu_plugin_bash_env | ||
plugin use bash_env | ||
} | ||
|
||
#[test] | ||
def test_echo [] { | ||
let actual = echo "export A=123" | bash-env | ||
let expected = { A: "123" } | ||
assert equal $actual $expected | ||
} | ||
|
||
#[test] | ||
def test_not_exported [] { | ||
let actual = echo "A=123" | bash-env | ||
let expected = { } | ||
assert equal $actual $expected | ||
} | ||
|
||
#[test] | ||
def test_export_shell_variables [] { | ||
let actual = echo "A=123" | bash-env --export [A] | ||
let expected = { A: "123" } | ||
assert equal $actual $expected | ||
} | ||
|
||
#[test] | ||
def test_export_shell_variables_missing [] { | ||
let actual = echo "A=123" | bash-env --export [A B] | ||
let expected = { A: "123" B: "" } | ||
assert equal $actual $expected | ||
} | ||
|
||
#[test] | ||
def test_shell_variables_from_file [] { | ||
let actual = bash-env tests/shell-variables.env | ||
let expected = { B: "exported" } | ||
assert equal $actual $expected | ||
} | ||
|
||
#[test] | ||
def test_export_shell_variables_from_file [] { | ||
let actual = bash-env --export [A] tests/shell-variables.env | ||
let expected = { A: "not exported" B: "exported" } | ||
assert equal $actual $expected | ||
} | ||
|
||
#[test] | ||
def test_empty_value [] { | ||
let actual = echo "export A=\"\"" | bash-env | ||
let expected = { A: "" } | ||
assert equal $actual $expected | ||
} | ||
|
||
#[test] | ||
def test_simple_file [] { | ||
let actual = bash-env tests/simple.env | ||
let expected = { A: "a" B: "b" } | ||
assert equal $actual $expected | ||
} | ||
|
||
#[test] | ||
def test_cat_simple_file [] { | ||
let actual = cat tests/simple.env | bash-env | ||
let expected = { A: "a" B: "b" } | ||
assert equal $actual $expected | ||
} | ||
|
||
#[test] | ||
def test_nasty_values_from_file [] { | ||
let actual = bash-env "tests/Ming's menu of (merciless) monstrosities.env" | ||
let expected = { | ||
SPACEMAN: "One small step for a man ..." | ||
QUOTE: "\"Well done!\" is better than \"Well said!\"" | ||
MIXED_BAG: "Did the sixth sheik's sixth sheep say \"baa\", or not?" | ||
} | ||
assert equal $actual $expected | ||
} | ||
|
||
#[test] | ||
def test_mixed [] { | ||
let actual = echo "export A=override-a C=sea" | bash-env tests/simple.env | ||
let expected = { A: "override-a" B: "b" C: "sea" } | ||
assert equal $actual $expected | ||
} | ||
|
||
add_and_use_plugin | ||
|
||
test_echo | ||
test_not_exported | ||
test_export_shell_variables | ||
test_export_shell_variables_missing | ||
test_shell_variables_from_file | ||
test_export_shell_variables_from_file | ||
test_empty_value | ||
test_simple_file | ||
test_cat_simple_file | ||
test_nasty_values_from_file | ||
test_mixed |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
A="not exported" | ||
export B="exported" |
File renamed without changes.
File renamed without changes.