aboutsummaryrefslogtreecommitdiffstats
path: root/repository_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-03-08 23:30:52 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-03-08 23:30:52 +0100
commitb35fc295b4ac531adc72fc83f2af628c7c163c0e (patch)
tree0282f20de8279db354233d1d67e3743e08509020 /repository_test.go
parent9c9cdff966cc181296f400769d3c8596f17e743a (diff)
parent9e6a03b7956464ccd9d2fbacedd8e5cc23572d02 (diff)
downloadgo-git-b35fc295b4ac531adc72fc83f2af628c7c163c0e.tar.gz
Merge pull request #39 from scjalliance/git-object-interface
Added Object interface for Commit, Tree, Blob and Tag
Diffstat (limited to 'repository_test.go')
-rw-r--r--repository_test.go32
1 files changed, 27 insertions, 5 deletions
diff --git a/repository_test.go b/repository_test.go
index 202c931..9e81334 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -15,8 +15,8 @@ type SuiteRepository struct {
var _ = Suite(&SuiteRepository{})
-func (s *SuiteRepository) SetUpTest(c *C) {
- s.repos = unpackFixtures(c, tagFixtures)
+func (s *SuiteRepository) SetUpSuite(c *C) {
+ s.repos = unpackFixtures(c, tagFixtures, treeWalkerFixtures)
}
func (s *SuiteRepository) TestNewRepository(c *C) {
@@ -58,6 +58,9 @@ func (s *SuiteRepository) TestCommit(c *C) {
c.Assert(err, IsNil)
c.Assert(commit.Hash.IsZero(), Equals, false)
+ c.Assert(commit.Hash, Equals, commit.ID())
+ c.Assert(commit.Hash, Equals, hash)
+ c.Assert(commit.Type(), Equals, core.CommitObject)
c.Assert(commit.Tree().Hash.IsZero(), Equals, false)
c.Assert(commit.Author.Email, Equals, "daniel@lordran.local")
}
@@ -79,6 +82,8 @@ func (s *SuiteRepository) TestCommits(c *C) {
count++
c.Assert(commit.Hash.IsZero(), Equals, false)
+ c.Assert(commit.Hash, Equals, commit.ID())
+ c.Assert(commit.Type(), Equals, core.CommitObject)
//c.Assert(commit.Tree.IsZero(), Equals, false)
}
@@ -90,10 +95,11 @@ func (s *SuiteRepository) TestTag(c *C) {
r, ok := s.repos[t.repo]
c.Assert(ok, Equals, true)
k := 0
- for hash, expected := range t.tags {
- tag, err := r.Tag(core.NewHash(hash))
+ for hashString, expected := range t.tags {
+ hash := core.NewHash(hashString)
+ tag, err := r.Tag(hash)
c.Assert(err, IsNil)
- testTagExpected(c, tag, expected, fmt.Sprintf("subtest %d, tag %d: ", i, k))
+ testTagExpected(c, tag, hash, expected, fmt.Sprintf("subtest %d, tag %d: ", i, k))
k++
}
}
@@ -107,6 +113,22 @@ func (s *SuiteRepository) TestTags(c *C) {
}
}
+func (s *SuiteRepository) TestObject(c *C) {
+ for i, t := range treeWalkerTests {
+ r, ok := s.repos[t.repo]
+ c.Assert(ok, Equals, true)
+ for k := 0; k < len(t.objs); k++ {
+ comment := fmt.Sprintf("subtest %d, tag %d", i, k)
+ info := t.objs[k]
+ hash := core.NewHash(info.Hash)
+ obj, err := r.Object(hash)
+ c.Assert(err, IsNil, Commentf(comment))
+ c.Assert(obj.Type(), Equals, info.Kind, Commentf(comment))
+ c.Assert(obj.ID(), Equals, hash, Commentf(comment))
+ }
+ }
+}
+
func (s *SuiteRepository) TestCommitIterClosePanic(c *C) {
r, err := NewRepository(RepositoryFixture, nil)
r.Remotes["origin"].upSrv = &MockGitUploadPackService{}