aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/utils/customflags_test.go
diff options
context:
space:
mode:
authorBas van Kervel <basvankervel@ziggo.nl>2015-04-08 21:43:55 +0800
committerBas van Kervel <basvankervel@ziggo.nl>2015-04-08 21:43:55 +0800
commit5304f43067c24e24eb8b8550c0db67fdbcc94718 (patch)
treef5f692078c8ae4c47ec56b47409e776751044b5d /cmd/utils/customflags_test.go
parent50aa1f178c71a4ff6c59888fcb9e78ff8a0abacd (diff)
downloadgo-tangerine-5304f43067c24e24eb8b8550c0db67fdbcc94718.tar
go-tangerine-5304f43067c24e24eb8b8550c0db67fdbcc94718.tar.gz
go-tangerine-5304f43067c24e24eb8b8550c0db67fdbcc94718.tar.bz2
go-tangerine-5304f43067c24e24eb8b8550c0db67fdbcc94718.tar.lz
go-tangerine-5304f43067c24e24eb8b8550c0db67fdbcc94718.tar.xz
go-tangerine-5304f43067c24e24eb8b8550c0db67fdbcc94718.tar.zst
go-tangerine-5304f43067c24e24eb8b8550c0db67fdbcc94718.zip
Add path expansion support for command line arguments, closes 567
Diffstat (limited to 'cmd/utils/customflags_test.go')
-rw-r--r--cmd/utils/customflags_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/cmd/utils/customflags_test.go b/cmd/utils/customflags_test.go
new file mode 100644
index 000000000..5674b939e
--- /dev/null
+++ b/cmd/utils/customflags_test.go
@@ -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)
+ }
+ }
+}