diff options
author | Sunny <me@darkowlzz.space> | 2017-10-04 18:52:21 +0530 |
---|---|---|
committer | Sunny <me@darkowlzz.space> | 2017-10-04 18:52:21 +0530 |
commit | b8eac90c420e14ebbabbb15523d024a4064e12ef (patch) | |
tree | 14f1ac91298ac56e848880ee0751c3a4fb78813d /remote_test.go | |
parent | 4d0c2cccb890be585b74fea3805db6e555f42cfc (diff) | |
download | go-git-b8eac90c420e14ebbabbb15523d024a4064e12ef.tar.gz |
TestList: explicitly check the refs in fixture
Diffstat (limited to 'remote_test.go')
-rw-r--r-- | remote_test.go | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/remote_test.go b/remote_test.go index f5f6817..30dab40 100644 --- a/remote_test.go +++ b/remote_test.go @@ -644,38 +644,32 @@ func (s *RemoteSuite) TestGetHaves(c *C) { } func (s *RemoteSuite) TestList(c *C) { - url := c.MkDir() - server, err := PlainInit(url, true) - c.Assert(err, IsNil) - - srcFs := fixtures.Basic().One().DotGit() - sto, err := filesystem.NewStorage(srcFs) - c.Assert(err, IsNil) - - remote := newRemote(sto, &config.RemoteConfig{ + repo := fixtures.Basic().One() + remote := newRemote(memory.NewStorage(), &config.RemoteConfig{ Name: DefaultRemoteName, - URLs: []string{url}, + URLs: []string{repo.URL}, }) - rs := config.RefSpec("refs/heads/*:refs/heads/*") - err = remote.Push(&PushOptions{ - RefSpecs: []config.RefSpec{rs}, - }) + refs, err := remote.List(&ListOptions{}) c.Assert(err, IsNil) - listOptions := ListOptions{} - refs, err := remote.List(&listOptions) - c.Assert(err, IsNil) - - // Create a map of remote name and their hash. - refsMap := map[string]string{} - for _, rf := range refs { - // Skip the symbolically linked HEAD. - if string(rf.Name()) == "HEAD" { - continue + expected := []*plumbing.Reference{ + plumbing.NewSymbolicReference("HEAD", "refs/heads/master"), + plumbing.NewReferenceFromStrings("refs/heads/master", "6ecf0ef2c2dffb796033e5a02219af86ec6584e5"), + plumbing.NewReferenceFromStrings("refs/heads/branch", "e8d3ffab552895c19b9fcf7aa264d277cde33881"), + plumbing.NewReferenceFromStrings("refs/pull/1/head", "b8e471f58bcbca63b07bda20e428190409c2db47"), + plumbing.NewReferenceFromStrings("refs/pull/2/head", "9632f02833b2f9613afb5e75682132b0b22e4a31"), + plumbing.NewReferenceFromStrings("refs/pull/2/merge", "c37f58a130ca555e42ff96a071cb9ccb3f437504"), + } + c.Assert(len(refs), Equals, len(expected)) + for _, e := range expected { + found := false + for _, r := range refs { + if r.Name() == e.Name() { + found = true + c.Assert(r, DeepEquals, e) + } } - refsMap[string(rf.Name())] = rf.Hash().String() + c.Assert(found, Equals, true) } - - AssertReferences(c, server, refsMap) } |