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 d89d96b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
4 changes: 2 additions & 2 deletions api/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ func (s *S) TestAddInvalidOldFormatHook(c *gocheck.C) {
c.Assert(recorder.Code, gocheck.Equals, 400)
}

func (s *S) TestAddKeyShouldReturnErrorWhenUserDoesNotExist(c *gocheck.C) { // FIXED
func (s *S) TestAddKeyShouldReturnErrorWhenUserDoesNotExist(c *gocheck.C) {
b := strings.NewReader(`{"key": "a public key"}`)
recorder, request := post("/user/Frodo/key", b, c)
s.router.ServeHTTP(recorder, request)
Expand Down Expand Up @@ -872,7 +872,7 @@ func (s *S) TestRemoveRepositoryShouldReturn400OnFailure(c *gocheck.C) {
c.Assert(recorder.Code, gocheck.Equals, 400)
}

func (s *S) TestRemoveRepositoryShouldReturnErrorMsgWhenRepoDoesNotExist(c *gocheck.C) { // FIXED
func (s *S) TestRemoveRepositoryShouldReturnErrorMsgWhenRepoDoesNotExist(c *gocheck.C) {
url := "/repository/foo"
request, err := http.NewRequest("DELETE", url, nil)
c.Assert(err, gocheck.IsNil)
Expand Down
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 d89d96b

Please sign in to comment.