diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2015-10-27 01:49:58 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2015-10-27 01:49:58 +0100 |
commit | 7d6c5a56c0b63705378f125523876de1a97fd1ce (patch) | |
tree | 8945a8a02d53f36a64304beaf006c4f46d61da48 /repository_test.go | |
parent | a2e49a59782a50a9ff116c6d17c6e3888502f2ad (diff) | |
download | go-git-7d6c5a56c0b63705378f125523876de1a97fd1ce.tar.gz |
tree and commit
Diffstat (limited to 'repository_test.go')
-rw-r--r-- | repository_test.go | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/repository_test.go b/repository_test.go index d0701fa..d377478 100644 --- a/repository_test.go +++ b/repository_test.go @@ -1,6 +1,9 @@ package git -import . "gopkg.in/check.v1" +import ( + . "gopkg.in/check.v1" + "gopkg.in/src-d/go-git.v2/internal" +) type SuiteRepository struct{} @@ -8,8 +11,47 @@ var _ = Suite(&SuiteRepository{}) func (s *SuiteRepository) TestPull(c *C) { r, err := NewRepository(RepositoryFixture) + r.Remotes["origin"].upSrv = &MockGitUploadPackService{} + + c.Assert(err, IsNil) + c.Assert(r.Pull("origin", "refs/heads/master"), IsNil) +} + +func (s *SuiteRepository) TestCommit(c *C) { + r, err := NewRepository(RepositoryFixture) + r.Remotes["origin"].upSrv = &MockGitUploadPackService{} + + c.Assert(err, IsNil) + c.Assert(r.Pull("origin", "refs/heads/master"), IsNil) + + hash := internal.NewHash("b8e471f58bcbca63b07bda20e428190409c2db47") + commit, err := r.Commit(hash) + c.Assert(err, IsNil) + + c.Assert(commit.Hash.IsZero(), Equals, false) + c.Assert(commit.Tree().Hash.IsZero(), Equals, false) + c.Assert(commit.Author.Email, Equals, "daniel@lordran.local") +} + +func (s *SuiteRepository) TestCommits(c *C) { + r, err := NewRepository(RepositoryFixture) + r.Remotes["origin"].upSrv = &MockGitUploadPackService{} + c.Assert(err, IsNil) c.Assert(r.Pull("origin", "refs/heads/master"), IsNil) - //fmt.Println(r.Storage) + count := 0 + commits := r.Commits() + for { + commit, err := commits.Next() + if err != nil { + break + } + + count++ + c.Assert(commit.Hash.IsZero(), Equals, false) + //c.Assert(commit.Tree.IsZero(), Equals, false) + } + + c.Assert(count, Equals, 8) } |