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

Commit

Permalink
Testing repository GetContent errors
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermef committed Jul 2, 2014
1 parent 56e0193 commit 00e6646
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions repository/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,3 +532,35 @@ func (s *S) TestGetFileContentIntegration(c *gocheck.C) {
c.Assert(err, gocheck.IsNil)
c.Assert(string(contents), gocheck.Equals, content)
}

func (s *S) TestGetFileContentWhenRefIsInvalid(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)
_, err := GetFileContents(repo, "MuchMissing", file)
c.Assert(err.Error(), gocheck.Equals, "Error when trying to obtain file README on ref MuchMissing of repository gandalf-test-repo (exit status 128).")
}

func (s *S) TestGetFileContentWhenFileIsInvalid(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)
_, err := GetFileContents(repo, "master", "Such file")
c.Assert(err.Error(), gocheck.Equals, "Error when trying to obtain file Such file on ref master of repository gandalf-test-repo (exit status 128).")
}

0 comments on commit 00e6646

Please sign in to comment.