From acd3dab95745bb91e1a1aee56ac8942f3197e859 Mon Sep 17 00:00:00 2001 From: Audrius Butkevicius Date: Mon, 9 Feb 2015 23:56:16 +0000 Subject: [PATCH] Fix tests on Windows --- internal/config/config.go | 11 +++++++---- internal/config/config_test.go | 4 ++-- internal/config/testdata/v1.xml | 2 +- internal/config/testdata/v2.xml | 2 +- internal/config/testdata/v3.xml | 2 +- internal/config/testdata/v4.xml | 2 +- internal/config/testdata/v5.xml | 2 +- internal/config/testdata/v6.xml | 2 +- internal/config/testdata/v7.xml | 2 +- 9 files changed, 16 insertions(+), 13 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index b796b8e94..b0e20717e 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -26,7 +26,6 @@ import ( "reflect" "sort" "strconv" - "strings" "github.com/calmh/logger" "github.com/syncthing/protocol" @@ -262,9 +261,13 @@ func (cfg *Configuration) prepare(myID protocol.DeviceID) { continue } - if !strings.HasSuffix(folder.Path, string(filepath.Separator)) { - folder.Path += string(filepath.Separator) - } + // The reason it's done like this: + // C: -> C:\ -> C:\ (issue that this is trying to fix) + // C:\somedir -> C:\somedir\ -> C:\somedir + // C:\somedir\ -> C:\somedir\\ -> C:\somedir + // This way in the tests, we get away without OS specific separators + // in the test configs. + folder.Path = filepath.Dir(folder.Path + string(filepath.Separator)) if folder.ID == "" { folder.ID = "default" diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 17b0a66d1..8ed96c7e8 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -84,7 +84,7 @@ func TestDeviceConfig(t *testing.T) { expectedFolders := []FolderConfiguration{ { ID: "test", - Path: "testdata/", + Path: "testdata", Devices: []FolderDeviceConfiguration{{DeviceID: device1}, {DeviceID: device4}}, ReadOnly: true, RescanIntervalS: 600, @@ -269,7 +269,7 @@ func TestIssue1262(t *testing.T) { } actual := cfg.Folders()["test"].Path - expected := "e:/" + expected := "e:" if runtime.GOOS == "windows" { expected = `e:\` } diff --git a/internal/config/testdata/v1.xml b/internal/config/testdata/v1.xml index a75154530..373d842d9 100755 --- a/internal/config/testdata/v1.xml +++ b/internal/config/testdata/v1.xml @@ -1,5 +1,5 @@ - +
a
diff --git a/internal/config/testdata/v2.xml b/internal/config/testdata/v2.xml index ef0fd7cfb..9aad846c7 100755 --- a/internal/config/testdata/v2.xml +++ b/internal/config/testdata/v2.xml @@ -1,5 +1,5 @@ - + diff --git a/internal/config/testdata/v3.xml b/internal/config/testdata/v3.xml index 5bd748500..dbb1d54d4 100755 --- a/internal/config/testdata/v3.xml +++ b/internal/config/testdata/v3.xml @@ -1,5 +1,5 @@ - + diff --git a/internal/config/testdata/v4.xml b/internal/config/testdata/v4.xml index c0a8e0010..17761d768 100755 --- a/internal/config/testdata/v4.xml +++ b/internal/config/testdata/v4.xml @@ -1,5 +1,5 @@ - + diff --git a/internal/config/testdata/v5.xml b/internal/config/testdata/v5.xml index 7daa88e14..48b763812 100755 --- a/internal/config/testdata/v5.xml +++ b/internal/config/testdata/v5.xml @@ -1,5 +1,5 @@ - + diff --git a/internal/config/testdata/v6.xml b/internal/config/testdata/v6.xml index ae73c0bc5..245a48681 100644 --- a/internal/config/testdata/v6.xml +++ b/internal/config/testdata/v6.xml @@ -1,5 +1,5 @@ - + diff --git a/internal/config/testdata/v7.xml b/internal/config/testdata/v7.xml index ec5bc6c1d..b637e864e 100644 --- a/internal/config/testdata/v7.xml +++ b/internal/config/testdata/v7.xml @@ -1,5 +1,5 @@ - +