diff options
author | Clemens Fries <github-clockrotz@xenoworld.de> | 2016-11-01 17:11:58 +0100 |
---|---|---|
committer | Clemens Fries <github-clockrotz@xenoworld.de> | 2016-11-01 17:11:58 +0100 |
commit | 533681e0f83ec4f69b3b8e9f1982ed9f089285b4 (patch) | |
tree | 4792c3b3e6b353798f8564ff90d6572081755e1f /clockrotz_test.go |
Initial commit
Diffstat (limited to 'clockrotz_test.go')
-rw-r--r-- | clockrotz_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/clockrotz_test.go b/clockrotz_test.go new file mode 100644 index 0000000..325438c --- /dev/null +++ b/clockrotz_test.go @@ -0,0 +1,34 @@ +package main + +import ( + "github.com/stretchr/testify/assert" + "testing" + . "github.com/githubert/clockrotz/common" +) + +func TestExpandTilde(t *testing.T) { + c := NewConfiguration() + + c.Set(CONF_WORKDIR, "/foo") + expandTilde(c) + assert.Equal(t, "/foo", c.Get(CONF_WORKDIR)) + + c.Set(CONF_WORKDIR, "~/foo") + expandTilde(c) + assert.Equal(t, userHome() + "/foo", c.Get(CONF_WORKDIR)) + + // Shortest possible + c.Set(CONF_WORKDIR, "~/") + expandTilde(c) + assert.Equal(t, userHome(), c.Get(CONF_WORKDIR)) + + // Single character workdir with only a tilde + c.Set(CONF_WORKDIR, "~") + expandTilde(c) + assert.Equal(t, userHome(), c.Get(CONF_WORKDIR)) + + // Ignored tilde + c.Set(CONF_WORKDIR, "~test") + expandTilde(c) + assert.Equal(t, "~test", c.Get(CONF_WORKDIR)) +}
\ No newline at end of file |