Debian Codegraph @

storage/filesystem/config_test.go

raw
1 package filesystem
2
3 import (
4 "os"
5
6 "github.com/go-git/go-billy/v5/osfs"
7 "github.com/go-git/go-billy/v5/util"
8 fixtures "github.com/go-git/go-git-fixtures/v4"
9 "github.com/go-git/go-git/v5/config"
10 "github.com/go-git/go-git/v5/storage/filesystem/dotgit"
11 . "gopkg.in/check.v1"
12 )
13
14 type ConfigSuite struct {
15 fixtures.Suite
16
17 dir *dotgit.DotGit
18 path string
19 }
20
21 var _ = Suite(&ConfigSuite{})
22
23 func (s *ConfigSuite) SetUpTest(c *C) {
24 tmp, err := util.TempDir(osfs.Default, "", "go-git-filestystem-config")
25 c.Assert(err, IsNil)
26
27 s.dir = dotgit.New(osfs.New(tmp))
28 s.path = tmp
29 }
30
31 func (s *ConfigSuite) TestRemotes(c *C) {
32 dir := dotgit.New(fixtures.Basic().ByTag(".git").One().DotGit())
33 storer := &ConfigStorage{dir}
34
35 cfg, err := storer.Config()
36 c.Assert(err, IsNil)
37
38 remotes := cfg.Remotes
39 c.Assert(remotes, HasLen, 1)
40 remote := remotes["origin"]
41 c.Assert(remote.Name, Equals, "origin")
42 c.Assert(remote.URLs, DeepEquals, []string{"https://github.com/git-fixtures/basic"})
43 c.Assert(remote.Fetch, DeepEquals, []config.RefSpec{config.RefSpec("+refs/heads/*:refs/remotes/origin/*")})
44 }
45
46 func (s *ConfigSuite) TearDownTest(c *C) {
47 defer os.RemoveAll(s.path)
48 }