aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Lazar <tlazar@signicast.com>2020-10-09 11:27:49 -0500
committerThomas Lazar <tlazar@signicast.com>2020-10-09 11:27:49 -0500
commit125fb621b9bd0ebc1adff2895ee646d4452459f4 (patch)
tree53601760180b8f2d558c11eeec2be638a90aadaf
parentec9b50d84022215ba78983155a3c44b51ccd4f52 (diff)
downloadgo-git-125fb621b9bd0ebc1adff2895ee646d4452459f4.tar.gz
add some tests
-rw-r--r--config/config_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/config/config_test.go b/config/config_test.go
index 21fa1ee..8108a94 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -4,6 +4,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
+ "strings"
"github.com/go-git/go-git/v5/plumbing"
. "gopkg.in/check.v1"
@@ -321,3 +322,29 @@ func (s *ConfigSuite) TestRemoteConfigDefaultValues(c *C) {
c.Assert(config.Raw, NotNil)
c.Assert(config.Pack.Window, Equals, DefaultPackWindow)
}
+
+func (s *ConfigSuite) TestLoadConfigLocalScope(c *C) {
+ cfg, err := LoadConfig(LocalScope)
+ c.Assert(err, NotNil)
+ c.Assert(cfg, IsNil)
+}
+
+func (s *ConfigSuite) TestRemoveUrlOptions(c *C) {
+ buf := []byte(`
+[remote "alt"]
+ url = git@github.com:mcuadros/go-git.git
+ url = git@github.com:src-d/go-git.git
+ fetch = +refs/heads/*:refs/remotes/origin/*
+ fetch = +refs/pull/*:refs/remotes/origin/pull/*`)
+
+ cfg := NewConfig()
+ err := cfg.Unmarshal(buf)
+ c.Assert(err, IsNil)
+ c.Assert(len(cfg.Remotes), Equals, 1)
+ cfg.Remotes["alt"].URLs = []string{}
+
+ buf, err = cfg.Marshal()
+ if strings.Contains(string(buf), "url") {
+ c.Fatal("conifg should not contain any url sections")
+ }
+}