diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-08-25 17:25:31 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-08-25 17:25:31 +0200 |
commit | a3418c5e0a3c6e925b5a4fb3ecb1d3db56408d1a (patch) | |
tree | 23ab46cb3269a104d9b69e0d1a1bec3c340df112 /repository_test.go | |
parent | 0f97041639b55bc4631145e2053a47a1eb8cdef0 (diff) | |
download | go-git-a3418c5e0a3c6e925b5a4fb3ecb1d3db56408d1a.tar.gz |
Repository: Clone protection if non empty object storage, Remote: NoErrAlreadyUpToDate
Diffstat (limited to 'repository_test.go')
-rw-r--r-- | repository_test.go | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/repository_test.go b/repository_test.go index ce53ead..bfb0298 100644 --- a/repository_test.go +++ b/repository_test.go @@ -106,6 +106,21 @@ func (s *RepositorySuite) TestClone(c *C) { c.Assert(branch.Hash().String(), Equals, "e8d3ffab552895c19b9fcf7aa264d277cde33881") } +func (s *RepositorySuite) TestCloneNonEmpty(c *C) { + r := NewMemoryRepository() + + head, err := r.Head() + c.Assert(err, Equals, core.ErrReferenceNotFound) + c.Assert(head, IsNil) + + o := &CloneOptions{URL: RepositoryFixture} + err = r.Clone(o) + c.Assert(err, IsNil) + + err = r.Clone(o) + c.Assert(err, Equals, ErrRepositoryNonEmpty) +} + func (s *RepositorySuite) TestCloneSingleBranchAndNonHEAD(c *C) { r := NewMemoryRepository() @@ -193,6 +208,21 @@ func (s *RepositorySuite) TestCloneDetachedHEAD(c *C) { c.Assert(head.Hash().String(), Equals, "6ecf0ef2c2dffb796033e5a02219af86ec6584e5") } +func (s *RepositorySuite) TestIsEmpty(c *C) { + r := NewMemoryRepository() + + empty, err := r.IsEmpty() + c.Assert(err, IsNil) + c.Assert(empty, Equals, true) + + err = r.Clone(&CloneOptions{URL: RepositoryFixture}) + c.Assert(err, IsNil) + + empty, err = r.IsEmpty() + c.Assert(err, IsNil) + c.Assert(empty, Equals, false) +} + func (s *RepositorySuite) TestCommit(c *C) { r := NewMemoryRepository() err := r.Clone(&CloneOptions{ @@ -237,7 +267,7 @@ func (s *RepositorySuite) TestCommits(c *C) { c.Assert(commit.Type(), Equals, core.CommitObject) } - c.Assert(count, Equals, 8) + c.Assert(count, Equals, 9) } func (s *RepositorySuite) TestTag(c *C) { |