Add path expansion support for command line arguments, closes 567
This commit is contained in:
28
cmd/utils/customflags_test.go
Normal file
28
cmd/utils/customflags_test.go
Normal file
@ -0,0 +1,28 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"os"
|
||||
"os/user"
|
||||
)
|
||||
|
||||
func TestPathExpansion(t *testing.T) {
|
||||
|
||||
user, _ := user.Current()
|
||||
|
||||
tests := map[string]string {
|
||||
"/home/someuser/tmp": "/home/someuser/tmp",
|
||||
"~/tmp": user.HomeDir + "/tmp",
|
||||
"$DDDXXX/a/b": "/tmp/a/b",
|
||||
"/a/b/": "/a/b",
|
||||
}
|
||||
|
||||
os.Setenv("DDDXXX", "/tmp")
|
||||
|
||||
for test, expected := range tests {
|
||||
got := expandPath(test)
|
||||
if got != expected {
|
||||
t.Errorf("test %s, got %s, expected %s\n", test, got, expected)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user