2023-03-16 19:23:29 +01:00
|
|
|
use std.nu
|
|
|
|
|
|
|
|
export def test_path_add [] {
|
2023-03-20 14:57:28 +01:00
|
|
|
use std.nu "assert equal"
|
2023-03-16 19:23:29 +01:00
|
|
|
|
|
|
|
with-env [PATH []] {
|
2023-03-20 14:57:28 +01:00
|
|
|
assert equal $env.PATH []
|
2023-03-16 19:23:29 +01:00
|
|
|
|
|
|
|
std path add "/foo/"
|
2023-03-20 14:57:28 +01:00
|
|
|
assert equal $env.PATH ["/foo/"]
|
2023-03-16 19:23:29 +01:00
|
|
|
|
|
|
|
std path add "/bar/" "/baz/"
|
2023-03-20 14:57:28 +01:00
|
|
|
assert equal $env.PATH ["/bar/", "/baz/", "/foo/"]
|
2023-03-16 19:23:29 +01:00
|
|
|
|
|
|
|
let-env PATH = []
|
|
|
|
|
|
|
|
std path add "foo"
|
|
|
|
std path add "bar" "baz" --append
|
2023-03-20 14:57:28 +01:00
|
|
|
assert equal $env.PATH ["foo", "bar", "baz"]
|
2023-03-16 19:23:29 +01:00
|
|
|
|
2023-03-20 14:57:28 +01:00
|
|
|
assert equal (std path add "fooooo" --ret) ["fooooo", "foo", "bar", "baz"]
|
|
|
|
assert equal $env.PATH ["fooooo", "foo", "bar", "baz"]
|
2023-03-16 19:23:29 +01:00
|
|
|
}
|
|
|
|
}
|