diff --git a/api/handler_test.go b/api/handler_test.go index 2be6599..6ef3c8f 100644 --- a/api/handler_test.go +++ b/api/handler_test.go @@ -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) @@ -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) diff --git a/repository/repository_test.go b/repository/repository_test.go index 286d4ea..0b9ac32 100644 --- a/repository/repository_test.go +++ b/repository/repository_test.go @@ -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"