2023-04-08 14:35:16 +02:00
|
|
|
use std
|
2023-03-16 19:23:29 +01:00
|
|
|
|
2023-07-02 10:41:33 +02:00
|
|
|
#[test]
|
|
|
|
def path_add [] {
|
2023-05-27 14:45:04 +02:00
|
|
|
use std assert
|
2023-03-16 19:23:29 +01:00
|
|
|
|
2023-05-18 01:55:46 +02:00
|
|
|
let path_name = if "PATH" in $env { "PATH" } else { "Path" }
|
|
|
|
|
|
|
|
with-env [$path_name []] {
|
|
|
|
def get_path [] { $env | get $path_name }
|
2023-06-10 20:16:17 +02:00
|
|
|
|
2023-05-18 01:55:46 +02:00
|
|
|
assert equal (get_path) []
|
2023-03-16 19:23:29 +01:00
|
|
|
|
|
|
|
std path add "/foo/"
|
2023-05-18 01:55:46 +02:00
|
|
|
assert equal (get_path) ["/foo/"]
|
2023-03-16 19:23:29 +01:00
|
|
|
|
|
|
|
std path add "/bar/" "/baz/"
|
2023-05-18 01:55:46 +02:00
|
|
|
assert equal (get_path) ["/bar/", "/baz/", "/foo/"]
|
2023-03-16 19:23:29 +01:00
|
|
|
|
2023-06-30 21:57:51 +02:00
|
|
|
load-env {$path_name: []}
|
2023-03-16 19:23:29 +01:00
|
|
|
|
|
|
|
std path add "foo"
|
|
|
|
std path add "bar" "baz" --append
|
2023-05-18 01:55:46 +02:00
|
|
|
assert equal (get_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"]
|
2023-05-18 01:55:46 +02:00
|
|
|
assert equal (get_path) ["fooooo", "foo", "bar", "baz"]
|
2023-05-26 09:24:53 +02:00
|
|
|
|
2023-06-30 21:57:51 +02:00
|
|
|
load-env {$path_name: []}
|
2023-05-26 09:24:53 +02:00
|
|
|
let target_paths = {linux: "foo", windows: "bar", macos: "baz"}
|
2023-06-10 20:16:17 +02:00
|
|
|
|
2023-05-26 09:24:53 +02:00
|
|
|
std path add $target_paths
|
|
|
|
assert equal (get_path) [($target_paths | get $nu.os-info.name)]
|
2023-03-16 19:23:29 +01:00
|
|
|
}
|
|
|
|
}
|
2023-05-10 14:05:01 +02:00
|
|
|
|
2023-07-02 10:41:33 +02:00
|
|
|
#[test]
|
|
|
|
def banner [] {
|
2023-05-10 14:05:01 +02:00
|
|
|
std assert ((std banner | lines | length) == 15)
|
|
|
|
}
|