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-28 01:01:32 +0300
committerbep <bjorn.erik.pedersen@gmail.com>2015-01-28 01:01:32 +0300
commite52a76f559b6c2f44a9dd32f7f01e7824f0246de (patch)
treec17a5d3ea76bc99063dac83ccea71618b6e7cbc5
parent0b5f8c8cb3a27669df99ce281100f4596f033db3 (diff)
Use runtime.GOOS to identify Windows specific path tests
-rw-r--r--helpers/path_test.go32
-rw-r--r--helpers/path_unix_test.go27
-rw-r--r--helpers/path_windows_test.go27
3 files changed, 32 insertions, 54 deletions
diff --git a/helpers/path_test.go b/helpers/path_test.go
index 366ed6e4c..bc0a54790 100644
--- a/helpers/path_test.go
+++ b/helpers/path_test.go
@@ -6,6 +6,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
+ "runtime"
"strconv"
"strings"
"testing"
@@ -398,6 +399,16 @@ func TestAbsPathify(t *testing.T) {
{"dir", filepath.FromSlash("/work"), filepath.FromSlash("/work/dir")},
}
+ windowsData := []test{
+ {"c:\\banana\\..\\dir", "c:\\foo", "c:\\dir"},
+ {"\\dir", "c:\\foo", "c:\\foo\\dir"},
+ {"c:\\", "c:\\foo", "c:\\"},
+ }
+
+ unixData := []test{
+ {"/banana/../dir/", "/work", "/dir"},
+ }
+
for i, d := range data {
// todo see comment in AbsPathify
viper.Set("WorkingDir", d.workingDir)
@@ -407,6 +418,27 @@ func TestAbsPathify(t *testing.T) {
t.Errorf("Test %d failed. Expected %q but got %q", i, d.expected, expected)
}
}
+ t.Logf("Running platform specific path tests for %s", runtime.GOOS)
+ if runtime.GOOS == "windows" {
+ for i, d := range windowsData {
+ 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)
+ }
+ }
+ } else {
+ for i, d := range unixData {
+ 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)
+ }
+ }
+ }
+
}
func TestFilename(t *testing.T) {
diff --git a/helpers/path_unix_test.go b/helpers/path_unix_test.go
deleted file mode 100644
index d9f73c6ef..000000000
--- a/helpers/path_unix_test.go
+++ /dev/null
@@ -1,27 +0,0 @@
-// +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
deleted file mode 100644
index 22b24ce31..000000000
--- a/helpers/path_windows_test.go
+++ /dev/null
@@ -1,27 +0,0 @@
-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)
- }
- }
-}