From 5304f43067c24e24eb8b8550c0db67fdbcc94718 Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Wed, 8 Apr 2015 15:43:55 +0200 Subject: Add path expansion support for command line arguments, closes 567 --- cmd/utils/customflags_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 cmd/utils/customflags_test.go (limited to 'cmd/utils/customflags_test.go') 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) + } + } +} -- cgit v1.2.3 From 6da5b2fc5fc0fe703158411afcd4f05add0336f2 Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Thu, 9 Apr 2015 10:26:26 +0200 Subject: reformat code with goimports --- cmd/utils/customflags_test.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'cmd/utils/customflags_test.go') diff --git a/cmd/utils/customflags_test.go b/cmd/utils/customflags_test.go index 5674b939e..11deb38ef 100644 --- a/cmd/utils/customflags_test.go +++ b/cmd/utils/customflags_test.go @@ -1,28 +1,28 @@ package utils import ( - "testing" - "os" - "os/user" + "os" + "os/user" + "testing" ) func TestPathExpansion(t *testing.T) { - user, _ := user.Current() + 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", - } + 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") + 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) - } - } + for test, expected := range tests { + got := expandPath(test) + if got != expected { + t.Errorf("test %s, got %s, expected %s\n", test, got, expected) + } + } } -- cgit v1.2.3