diff options
author | Santiago M. Mola <santi@mola.io> | 2016-12-19 23:36:44 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-12-19 23:36:44 +0100 |
commit | 90d67bb648ae32d5b1a0f7b1af011da6dfb24315 (patch) | |
tree | fc8c14e82974be6ff49e842328ec3206ebf1b4c2 /plumbing/transport/test | |
parent | 725ade0de6f60549e65cc4d94094b1f5ed48587f (diff) | |
download | go-git-90d67bb648ae32d5b1a0f7b1af011da6dfb24315.tar.gz |
remote: add Push (#178)
* remote: add Push.
* add Push method to Remote.
* add method Push to Repository.
* examples: add push example.
* requested changes
* add tests, fixes
Diffstat (limited to 'plumbing/transport/test')
-rw-r--r-- | plumbing/transport/test/send_pack.go | 53 |
1 files changed, 45 insertions, 8 deletions
diff --git a/plumbing/transport/test/send_pack.go b/plumbing/transport/test/send_pack.go index 8cb549d..f880588 100644 --- a/plumbing/transport/test/send_pack.go +++ b/plumbing/transport/test/send_pack.go @@ -131,7 +131,7 @@ func (s *SendPackSuite) TestFullSendPackOnNonEmpty(c *C) { fixture := fixtures.Basic().ByTag("packfile").One() req := packp.NewReferenceUpdateRequest() req.Commands = []*packp.Command{ - {"refs/heads/master", plumbing.ZeroHash, fixture.Head}, + {"refs/heads/master", fixture.Head, fixture.Head}, } s.sendPack(c, endpoint, req, fixture, full) s.checkRemoteHead(c, endpoint, fixture.Head) @@ -143,7 +143,7 @@ func (s *SendPackSuite) TestSendPackOnNonEmpty(c *C) { fixture := fixtures.Basic().ByTag("packfile").One() req := packp.NewReferenceUpdateRequest() req.Commands = []*packp.Command{ - {"refs/heads/master", plumbing.ZeroHash, fixture.Head}, + {"refs/heads/master", fixture.Head, fixture.Head}, } s.sendPack(c, endpoint, req, fixture, full) s.checkRemoteHead(c, endpoint, fixture.Head) @@ -155,7 +155,7 @@ func (s *SendPackSuite) TestSendPackOnNonEmptyWithReportStatus(c *C) { fixture := fixtures.Basic().ByTag("packfile").One() req := packp.NewReferenceUpdateRequest() req.Commands = []*packp.Command{ - {"refs/heads/master", plumbing.ZeroHash, fixture.Head}, + {"refs/heads/master", fixture.Head, fixture.Head}, } req.Capabilities.Set(capability.ReportStatus) @@ -163,10 +163,30 @@ func (s *SendPackSuite) TestSendPackOnNonEmptyWithReportStatus(c *C) { s.checkRemoteHead(c, endpoint, fixture.Head) } -func (s *SendPackSuite) sendPack(c *C, ep transport.Endpoint, - req *packp.ReferenceUpdateRequest, fixture *fixtures.Fixture, - callAdvertisedReferences bool) { +func (s *SendPackSuite) TestSendPackOnNonEmptyWithReportStatusWithError(c *C) { + endpoint := s.Endpoint + full := false + fixture := fixtures.Basic().ByTag("packfile").One() + req := packp.NewReferenceUpdateRequest() + req.Commands = []*packp.Command{ + {"refs/heads/master", plumbing.ZeroHash, fixture.Head}, + } + req.Capabilities.Set(capability.ReportStatus) + + report, err := s.sendPackNoCheck(c, endpoint, req, fixture, full) + //XXX: Recent git versions return "failed to update ref", while older + // (>=1.9) return "failed to lock". + c.Assert(err, ErrorMatches, ".*(failed to update ref|failed to lock).*") + c.Assert(report.UnpackStatus, Equals, "ok") + c.Assert(len(report.CommandStatuses), Equals, 1) + c.Assert(report.CommandStatuses[0].ReferenceName, Equals, plumbing.ReferenceName("refs/heads/master")) + c.Assert(report.CommandStatuses[0].Status, Matches, "(failed to update ref|failed to lock)") + s.checkRemoteHead(c, endpoint, fixture.Head) +} +func (s *SendPackSuite) sendPackNoCheck(c *C, ep transport.Endpoint, + req *packp.ReferenceUpdateRequest, fixture *fixtures.Fixture, + callAdvertisedReferences bool) (*packp.ReportStatus, error) { url := "" if fixture != nil { url = fixture.URL @@ -193,11 +213,28 @@ func (s *SendPackSuite) sendPack(c *C, ep transport.Endpoint, req.Packfile = s.emptyPackfile() } - report, err := r.SendPack(req) + return r.SendPack(req) +} + +func (s *SendPackSuite) sendPack(c *C, ep transport.Endpoint, + req *packp.ReferenceUpdateRequest, fixture *fixtures.Fixture, + callAdvertisedReferences bool) { + + url := "" + if fixture != nil { + url = fixture.URL + } + + comment := Commentf( + "failed with ep=%s fixture=%s callAdvertisedReferences=%s", + ep.String(), url, callAdvertisedReferences, + ) + report, err := s.sendPackNoCheck(c, ep, req, fixture, callAdvertisedReferences) + c.Assert(err, IsNil, comment) if req.Capabilities.Supports(capability.ReportStatus) { c.Assert(report, NotNil, comment) - c.Assert(report.Ok(), Equals, true, comment) + c.Assert(report.Error(), IsNil, comment) } else { c.Assert(report, IsNil, comment) } |