aboutsummaryrefslogtreecommitdiffstats
path: root/repository_test.go
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2016-12-16 19:31:01 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-12-16 19:31:01 +0100
commitb3adbed0ce15d82bf41d23cc507c5dd47a6c4260 (patch)
tree156ce904ed4af15d89a85876e3585e4c55204ae8 /repository_test.go
parent950676c36030a8796c0a69a8aae606ff1f448b03 (diff)
downloadgo-git-b3adbed0ce15d82bf41d23cc507c5dd47a6c4260.tar.gz
remote: make Fetch atomic. (#185)
* Remote now exposes only Fetch. No Connect, Disconnect, etc. * Repository uses a private fetch method in Remote for Clone/Pull. * getting capabilities, HEAD or other information from remote requires using the lower level client. * add Fetch method to Repository.
Diffstat (limited to 'repository_test.go')
-rw-r--r--repository_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/repository_test.go b/repository_test.go
index 91a5c71..4d17dce 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -84,6 +84,29 @@ func (s *RepositorySuite) TestDeleteRemote(c *C) {
c.Assert(alt, IsNil)
}
+func (s *RepositorySuite) TestFetch(c *C) {
+ r := NewMemoryRepository()
+ _, err := r.CreateRemote(&config.RemoteConfig{
+ Name: DefaultRemoteName,
+ URL: s.GetBasicLocalRepositoryURL(),
+ })
+ c.Assert(err, IsNil)
+ c.Assert(r.Fetch(&FetchOptions{}), IsNil)
+
+ remotes, err := r.Remotes()
+ c.Assert(err, IsNil)
+ c.Assert(remotes, HasLen, 1)
+
+ _, err = r.Reference(plumbing.HEAD, false)
+ c.Assert(err, Equals, plumbing.ErrReferenceNotFound)
+
+ branch, err := r.Reference("refs/remotes/origin/master", false)
+ c.Assert(err, IsNil)
+ c.Assert(branch, NotNil)
+ c.Assert(branch.Type(), Equals, plumbing.HashReference)
+ c.Assert(branch.Hash().String(), Equals, "6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
+}
+
func (s *RepositorySuite) TestClone(c *C) {
r := NewMemoryRepository()