Skip to content

Commit

Permalink
merge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rubiojr committed Oct 25, 2020
1 parent d9b3d51 commit d097b0f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
6 changes: 3 additions & 3 deletions cfg/aesbackend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand All @@ -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")
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion cfg/filebackend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
20 changes: 3 additions & 17 deletions cfg/filebackend_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package cfg

import (
<<<<<<< HEAD
"io/ioutil"
"net/url"
=======
>>>>>>> :lipstick:
"os"
"path/filepath"
"testing"
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand All @@ -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")
}
Expand All @@ -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")
}
Expand Down

0 comments on commit d097b0f

Please sign in to comment.