Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbep <bjorn.erik.pedersen@gmail.com>2015-01-27 16:03:48 +0300
committerbep <bjorn.erik.pedersen@gmail.com>2015-01-27 17:09:01 +0300
commit8ad4fd05d8dff450c8ceffd58483497d9f0e6d88 (patch)
tree7b5afa8dbf767594a62d1d643bcac630db68d42b
parentb155e8b4cbde764f326ac989b060c805da26e176 (diff)
Split Windows and Unix specific path tests
-rw-r--r--helpers/path_test.go1
-rw-r--r--helpers/path_unix_test.go27
-rw-r--r--helpers/path_windows_test.go27
3 files changed, 54 insertions, 1 deletions
diff --git a/helpers/path_test.go b/helpers/path_test.go
index f4d3dd303..366ed6e4c 100644
--- a/helpers/path_test.go
+++ b/helpers/path_test.go
@@ -395,7 +395,6 @@ func TestAbsPathify(t *testing.T) {
}
data := []test{
{os.TempDir(), filepath.FromSlash("/work"), filepath.Clean(os.TempDir())}, // TempDir has trailing slash
- // todo bep breaks on Windows: {filepath.FromSlash("/banana/../dir/"), filepath.FromSlash("/work"), filepath.FromSlash("/dir")},
{"dir", filepath.FromSlash("/work"), filepath.FromSlash("/work/dir")},
}
diff --git a/helpers/path_unix_test.go b/helpers/path_unix_test.go
new file mode 100644
index 000000000..d9f73c6ef
--- /dev/null
+++ b/helpers/path_unix_test.go
@@ -0,0 +1,27 @@
+// +build !windows
+
+package helpers
+
+import (
+ "github.com/spf13/viper"
+ "testing"
+)
+
+func TestPlatformAbsPathify(t *testing.T) {
+ type test struct {
+ inPath, workingDir, expected string
+ }
+ data := []test{
+ {"/banana/../dir/", "/work", "/dir"},
+ }
+
+ for i, d := range data {
+ // todo see comment in AbsPathify
+ viper.Set("WorkingDir", d.workingDir)
+
+ expected := AbsPathify(d.inPath)
+ if d.expected != expected {
+ t.Errorf("Test %d failed. Expected %q but got %q", i, d.expected, expected)
+ }
+ }
+}
diff --git a/helpers/path_windows_test.go b/helpers/path_windows_test.go
new file mode 100644
index 000000000..22b24ce31
--- /dev/null
+++ b/helpers/path_windows_test.go
@@ -0,0 +1,27 @@
+package helpers
+
+import (
+ "github.com/spf13/viper"
+ "testing"
+)
+
+func TestPlatformAbsPathify(t *testing.T) {
+ type test struct {
+ inPath, workingDir, expected string
+ }
+ data := []test{
+ {"c:\\banana\\..\\dir", "c:\\foo", "c:\\dir"},
+ {"\\dir", "c:\\foo", "c:\\foo\\dir"},
+ {"c:\\", "c:\\foo", "c:\\"},
+ }
+
+ for i, d := range data {
+ // todo see comment in AbsPathify
+ viper.Set("WorkingDir", d.workingDir)
+
+ expected := AbsPathify(d.inPath)
+ if d.expected != expected {
+ t.Errorf("Test %d failed. Expected %q but got %q", i, d.expected, expected)
+ }
+ }
+}