From d097b0fcec10c4f12db845771e97fdade69affeb Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Sun, 25 Oct 2020 13:41:25 +0100 Subject: [PATCH] merge fixes --- cfg/aesbackend_test.go | 6 +++--- cfg/filebackend.go | 1 - cfg/filebackend_test.go | 20 +++----------------- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/cfg/aesbackend_test.go b/cfg/aesbackend_test.go index b4616cdd..2c8b8470 100644 --- a/cfg/aesbackend_test.go +++ b/cfg/aesbackend_test.go @@ -106,7 +106,7 @@ func TestAESBackendLoad(t *testing.T) { if err != nil { t.Fatalf("Can't parse crypto URL: %v", err) } - conf, err = backend.Load(u) + _, err = backend.Load(u) if err == nil || err.Error() != "encrypted configuration header not valid" { t.Errorf("Loading a non-encrypted config should error") } @@ -125,7 +125,7 @@ func TestAESBackendSave(t *testing.T) { } // Save the config file to a new absolute path using a URL - p := encryptedTempConf() + p = encryptedTempConf() u, err = ParseURL("crypto://" + testPassword + "@" + p) if err != nil { t.Error("cannot parse config url") @@ -137,7 +137,7 @@ func TestAESBackendSave(t *testing.T) { backend, _ = NewAESBackend(u) err = backend.Save(c) if err != nil { - t.Errorf("failed to save the config to %s. %v", newURL, err) + t.Errorf("failed to save the config to %s. %v", u, err) } if !exist(p) { t.Errorf("configuration file wasn't saved to %s", p) diff --git a/cfg/filebackend.go b/cfg/filebackend.go index db91ceb7..6d12d580 100644 --- a/cfg/filebackend.go +++ b/cfg/filebackend.go @@ -31,7 +31,6 @@ func NewFileBackend() *FileBackend { // Load loads chains from config func (fs *FileBackend) Load(u *URL) (*Config, error) { var config Config - fixWinURL(u) // detect file format by extension if strings.HasSuffix(u.Path, ".yaml") { diff --git a/cfg/filebackend_test.go b/cfg/filebackend_test.go index e43ce26a..848bfe3a 100644 --- a/cfg/filebackend_test.go +++ b/cfg/filebackend_test.go @@ -1,11 +1,7 @@ package cfg import ( -<<<<<<< HEAD "io/ioutil" - "net/url" -======= ->>>>>>> :lipstick: "os" "path/filepath" "testing" @@ -23,11 +19,7 @@ func TestFileLoad(t *testing.T) { // try to load the config from a relative path u, err = ParseURL(filepath.Join("testdata", "beehive.conf")) if err != nil { -<<<<<<< HEAD - t.Error("cannot parse config path") -======= t.Fatalf("Can't parse URL. %v", err) ->>>>>>> Test fixes } backend = NewFileBackend() conf, err := backend.Load(u) @@ -56,6 +48,7 @@ func TestFileLoad(t *testing.T) { } func TestFileSave(t *testing.T) { + tmpdir, err := ioutil.TempDir("", "beehivetest") u, err := ParseURL(filepath.Join("testdata", "beehive.conf")) if err != nil { t.Fatalf("Can't parse URL. %v", err) @@ -91,17 +84,10 @@ func TestFileSave(t *testing.T) { // Save the config file to a new absolute path using a regular path p = tmpConfPath() -<<<<<<< HEAD c.SetURL(p) u, err = ParseURL(p) if err != nil { t.Error("cannot parse url") -======= - c, err = New(p) - if err != nil { - t.Errorf("Error creating config file") - ->>>>>>> moar test fixes } err = backend.Save(c) if err != nil { @@ -114,7 +100,7 @@ func TestFileSave(t *testing.T) { func Test_FileLoad_FileSave_YAML(t *testing.T) { // load - u, err := url.Parse(filepath.Join("testdata", "beehive.yaml")) + u, err := ParseURL(filepath.Join("testdata", "beehive.yaml")) if err != nil { t.Error("cannot parse config path") } @@ -132,7 +118,7 @@ func Test_FileLoad_FileSave_YAML(t *testing.T) { t.Error("Could not create temp directory") } p := filepath.Join(tmpdir, "beehive.yaml") - u, err = url.Parse("file://" + p) + u, err = ParseURL("file://" + p) if err != nil { t.Error("cannot parse config path") }