summaryrefslogtreecommitdiffstats
path: root/helpers/path_test.go
diff options
context:
space:
mode:
authorCyrill Schumacher <cyrill@schumacher.fm>2014-12-27 14:40:10 +1100
committerspf13 <steve.francia@gmail.com>2015-02-17 12:14:39 -0500
commit5e2d3d2e10a4cf1935c2226b023bde2f3ce9e7c0 (patch)
tree9e47a2aead8bbddeda8991b874afd628df005dbe /helpers/path_test.go
parent9bf223e584e115569bf2ffe64c3118e54d021a90 (diff)
Merge to stay up to date with current dev
Feature: GetJson and GetJson in short codes or other layout files. For more details please see: http://cyrillschumacher.com/2014/12/21/dynamic-pages-with-gohugo.io/
Diffstat (limited to 'helpers/path_test.go')
-rw-r--r--helpers/path_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/helpers/path_test.go b/helpers/path_test.go
index bc0a54790..9be1c9fc4 100644
--- a/helpers/path_test.go
+++ b/helpers/path_test.go
@@ -647,3 +647,31 @@ func TestWriteToDisk(t *testing.T) {
reader.Seek(0, 0)
}
}
+
+func TestGetTempDir(t *testing.T) {
+ dir := os.TempDir()
+ if FilePathSeparator != dir[len(dir)-1:] {
+ dir = dir + FilePathSeparator
+ }
+ testDir := "hugoTestFolder" + FilePathSeparator
+ tests := []struct {
+ input string
+ expected string
+ }{
+ {"", dir},
+ {testDir + " Foo bar ", dir + testDir + "--Foo-bar" + FilePathSeparator},
+ {testDir + "Foo.Bar/foo_Bar-Foo", dir + testDir + "Foo.Bar/foo_Bar-Foo" + FilePathSeparator},
+ {testDir + "fOO,bar:foo%bAR", dir + testDir + "fOObarfoobAR" + FilePathSeparator},
+ {testDir + "FOo/BaR.html", dir + testDir + "FOo/BaR.html" + FilePathSeparator},
+ {testDir + "трям/трям", dir + testDir + "трям/трям" + FilePathSeparator},
+ {testDir + "은행", dir + testDir + "은행" + FilePathSeparator},
+ {testDir + "Банковский кассир", dir + testDir + "Банковский-кассир" + FilePathSeparator},
+ }
+
+ for _, test := range tests {
+ output := GetTempDir(test.input, new(afero.MemMapFs))
+ if output != test.expected {
+ t.Errorf("Expected %#v, got %#v\n", test.expected, output)
+ }
+ }
+}