Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

Commit

Permalink
Increase repository.GetForEachRef coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
scorphus committed Sep 1, 2014
1 parent 35f9ec8 commit b2b2fb9
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions repository/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,45 @@ func (s *S) TestGetForEachRefIntegrationWhenPatternInvalid(c *gocheck.C) {
c.Assert(err.Error(), gocheck.Equals, "Error when trying to obtain the refs of repository gandalf-test-repo (exit status 129).")
}

func (s *S) TestGetForEachRefOutputInvalid(c *gocheck.C) {
oldBare := bare
bare = "/tmp"
repo := "gandalf-test-repo"
file := "README"
content := "much WOW"
cleanUp, errCreate := CreateTestRepository(bare, repo, file, content)
defer func() {
cleanUp()
bare = oldBare
}()
c.Assert(errCreate, gocheck.IsNil)
tmpdir, err := commandmocker.Add("git", "-")
c.Assert(err, gocheck.IsNil)
defer commandmocker.Remove(tmpdir)
_, err = GetForEachRef(repo, "")
c.Assert(err.Error(), gocheck.Equals, "Error when trying to obtain the refs of repository gandalf-test-repo (Invalid git for-each-ref output [-]).")
}

func (s *S) TestGetForEachRefOutputEmpty(c *gocheck.C) {
oldBare := bare
bare = "/tmp"
repo := "gandalf-test-repo"
file := "README"
content := "much WOW"
cleanUp, errCreate := CreateTestRepository(bare, repo, file, content)
defer func() {
cleanUp()
bare = oldBare
}()
c.Assert(errCreate, gocheck.IsNil)
tmpdir, err := commandmocker.Add("git", "\n")
c.Assert(err, gocheck.IsNil)
defer commandmocker.Remove(tmpdir)
refs, err := GetForEachRef(repo, "")
c.Assert(err, gocheck.IsNil)
c.Assert(refs, gocheck.HasLen, 0)
}

func (s *S) TestGetDiffIntegration(c *gocheck.C) {
oldBare := bare
bare = "/tmp"
Expand Down

0 comments on commit b2b2fb9

Please sign in to comment.