Skip to content

Commit

Permalink
add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Lazar committed Oct 9, 2020
1 parent ec9b50d commit 125fb62
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions config/config_test.go
Expand Up @@ -4,6 +4,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strings"

"github.com/go-git/go-git/v5/plumbing"
. "gopkg.in/check.v1"
Expand Down Expand Up @@ -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")
}
}

0 comments on commit 125fb62

Please sign in to comment.