diff options
Diffstat (limited to 'plumbing/transport/test')
-rw-r--r-- | plumbing/transport/test/receive_pack.go (renamed from plumbing/transport/test/send_pack.go) | 96 | ||||
-rw-r--r-- | plumbing/transport/test/upload_pack.go (renamed from plumbing/transport/test/fetch_pack.go) | 80 |
2 files changed, 88 insertions, 88 deletions
diff --git a/plumbing/transport/test/send_pack.go b/plumbing/transport/test/receive_pack.go index f880588..e798154 100644 --- a/plumbing/transport/test/send_pack.go +++ b/plumbing/transport/test/receive_pack.go @@ -19,44 +19,44 @@ import ( . "gopkg.in/check.v1" ) -type SendPackSuite struct { +type ReceivePackSuite struct { Endpoint transport.Endpoint EmptyEndpoint transport.Endpoint NonExistentEndpoint transport.Endpoint - Client transport.Client + Client transport.Transport } -func (s *SendPackSuite) TestInfoEmpty(c *C) { - r, err := s.Client.NewSendPackSession(s.EmptyEndpoint) +func (s *ReceivePackSuite) TestAdvertisedReferencesEmpty(c *C) { + r, err := s.Client.NewReceivePackSession(s.EmptyEndpoint) c.Assert(err, IsNil) defer func() { c.Assert(r.Close(), IsNil) }() - info, err := r.AdvertisedReferences() + ar, err := r.AdvertisedReferences() c.Assert(err, IsNil) - c.Assert(info.Head, IsNil) + c.Assert(ar.Head, IsNil) } -func (s *SendPackSuite) TestInfoNotExists(c *C) { - r, err := s.Client.NewSendPackSession(s.NonExistentEndpoint) +func (s *ReceivePackSuite) TestAdvertisedReferencesNotExists(c *C) { + r, err := s.Client.NewReceivePackSession(s.NonExistentEndpoint) c.Assert(err, IsNil) defer func() { c.Assert(r.Close(), IsNil) }() - info, err := r.AdvertisedReferences() + ar, err := r.AdvertisedReferences() c.Assert(err, Equals, transport.ErrRepositoryNotFound) - c.Assert(info, IsNil) + c.Assert(ar, IsNil) - r, err = s.Client.NewSendPackSession(s.NonExistentEndpoint) + r, err = s.Client.NewReceivePackSession(s.NonExistentEndpoint) c.Assert(err, IsNil) req := packp.NewReferenceUpdateRequest() req.Commands = []*packp.Command{ {"master", plumbing.ZeroHash, plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")}, } - writer, err := r.SendPack(req) + writer, err := r.ReceivePack(req) c.Assert(err, Equals, transport.ErrRepositoryNotFound) c.Assert(writer, IsNil) } -func (s *SendPackSuite) TestCallAdvertisedReferenceTwice(c *C) { - r, err := s.Client.NewSendPackSession(s.Endpoint) +func (s *ReceivePackSuite) TestCallAdvertisedReferenceTwice(c *C) { + r, err := s.Client.NewReceivePackSession(s.Endpoint) c.Assert(err, IsNil) ar1, err := r.AdvertisedReferences() c.Assert(err, IsNil) @@ -66,8 +66,8 @@ func (s *SendPackSuite) TestCallAdvertisedReferenceTwice(c *C) { c.Assert(ar2, DeepEquals, ar1) } -func (s *SendPackSuite) TestDefaultBranch(c *C) { - r, err := s.Client.NewSendPackSession(s.Endpoint) +func (s *ReceivePackSuite) TestDefaultBranch(c *C) { + r, err := s.Client.NewReceivePackSession(s.Endpoint) c.Assert(err, IsNil) defer func() { c.Assert(r.Close(), IsNil) }() @@ -78,8 +78,8 @@ func (s *SendPackSuite) TestDefaultBranch(c *C) { c.Assert(ref, Equals, fixtures.Basic().One().Head) } -func (s *SendPackSuite) TestCapabilities(c *C) { - r, err := s.Client.NewSendPackSession(s.Endpoint) +func (s *ReceivePackSuite) TestCapabilities(c *C) { + r, err := s.Client.NewReceivePackSession(s.Endpoint) c.Assert(err, IsNil) defer func() { c.Assert(r.Close(), IsNil) }() @@ -88,7 +88,7 @@ func (s *SendPackSuite) TestCapabilities(c *C) { c.Assert(info.Capabilities.Get("agent"), HasLen, 1) } -func (s *SendPackSuite) TestFullSendPackOnEmpty(c *C) { +func (s *ReceivePackSuite) TestFullSendPackOnEmpty(c *C) { endpoint := s.EmptyEndpoint full := true fixture := fixtures.Basic().ByTag("packfile").One() @@ -96,11 +96,11 @@ func (s *SendPackSuite) TestFullSendPackOnEmpty(c *C) { req.Commands = []*packp.Command{ {"refs/heads/master", plumbing.ZeroHash, fixture.Head}, } - s.sendPack(c, endpoint, req, fixture, full) + s.receivePack(c, endpoint, req, fixture, full) s.checkRemoteHead(c, endpoint, fixture.Head) } -func (s *SendPackSuite) TestSendPackOnEmpty(c *C) { +func (s *ReceivePackSuite) TestSendPackOnEmpty(c *C) { endpoint := s.EmptyEndpoint full := false fixture := fixtures.Basic().ByTag("packfile").One() @@ -108,11 +108,11 @@ func (s *SendPackSuite) TestSendPackOnEmpty(c *C) { req.Commands = []*packp.Command{ {"refs/heads/master", plumbing.ZeroHash, fixture.Head}, } - s.sendPack(c, endpoint, req, fixture, full) + s.receivePack(c, endpoint, req, fixture, full) s.checkRemoteHead(c, endpoint, fixture.Head) } -func (s *SendPackSuite) TestSendPackOnEmptyWithReportStatus(c *C) { +func (s *ReceivePackSuite) TestSendPackOnEmptyWithReportStatus(c *C) { endpoint := s.EmptyEndpoint full := false fixture := fixtures.Basic().ByTag("packfile").One() @@ -121,11 +121,11 @@ func (s *SendPackSuite) TestSendPackOnEmptyWithReportStatus(c *C) { {"refs/heads/master", plumbing.ZeroHash, fixture.Head}, } req.Capabilities.Set(capability.ReportStatus) - s.sendPack(c, endpoint, req, fixture, full) + s.receivePack(c, endpoint, req, fixture, full) s.checkRemoteHead(c, endpoint, fixture.Head) } -func (s *SendPackSuite) TestFullSendPackOnNonEmpty(c *C) { +func (s *ReceivePackSuite) TestFullSendPackOnNonEmpty(c *C) { endpoint := s.Endpoint full := true fixture := fixtures.Basic().ByTag("packfile").One() @@ -133,11 +133,11 @@ func (s *SendPackSuite) TestFullSendPackOnNonEmpty(c *C) { req.Commands = []*packp.Command{ {"refs/heads/master", fixture.Head, fixture.Head}, } - s.sendPack(c, endpoint, req, fixture, full) + s.receivePack(c, endpoint, req, fixture, full) s.checkRemoteHead(c, endpoint, fixture.Head) } -func (s *SendPackSuite) TestSendPackOnNonEmpty(c *C) { +func (s *ReceivePackSuite) TestSendPackOnNonEmpty(c *C) { endpoint := s.Endpoint full := false fixture := fixtures.Basic().ByTag("packfile").One() @@ -145,11 +145,11 @@ func (s *SendPackSuite) TestSendPackOnNonEmpty(c *C) { req.Commands = []*packp.Command{ {"refs/heads/master", fixture.Head, fixture.Head}, } - s.sendPack(c, endpoint, req, fixture, full) + s.receivePack(c, endpoint, req, fixture, full) s.checkRemoteHead(c, endpoint, fixture.Head) } -func (s *SendPackSuite) TestSendPackOnNonEmptyWithReportStatus(c *C) { +func (s *ReceivePackSuite) TestSendPackOnNonEmptyWithReportStatus(c *C) { endpoint := s.Endpoint full := false fixture := fixtures.Basic().ByTag("packfile").One() @@ -159,11 +159,11 @@ func (s *SendPackSuite) TestSendPackOnNonEmptyWithReportStatus(c *C) { } req.Capabilities.Set(capability.ReportStatus) - s.sendPack(c, endpoint, req, fixture, full) + s.receivePack(c, endpoint, req, fixture, full) s.checkRemoteHead(c, endpoint, fixture.Head) } -func (s *SendPackSuite) TestSendPackOnNonEmptyWithReportStatusWithError(c *C) { +func (s *ReceivePackSuite) TestSendPackOnNonEmptyWithReportStatusWithError(c *C) { endpoint := s.Endpoint full := false fixture := fixtures.Basic().ByTag("packfile").One() @@ -173,7 +173,7 @@ func (s *SendPackSuite) TestSendPackOnNonEmptyWithReportStatusWithError(c *C) { } req.Capabilities.Set(capability.ReportStatus) - report, err := s.sendPackNoCheck(c, endpoint, req, fixture, full) + report, err := s.receivePackNoCheck(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).*") @@ -184,7 +184,7 @@ func (s *SendPackSuite) TestSendPackOnNonEmptyWithReportStatusWithError(c *C) { s.checkRemoteHead(c, endpoint, fixture.Head) } -func (s *SendPackSuite) sendPackNoCheck(c *C, ep transport.Endpoint, +func (s *ReceivePackSuite) receivePackNoCheck(c *C, ep transport.Endpoint, req *packp.ReferenceUpdateRequest, fixture *fixtures.Fixture, callAdvertisedReferences bool) (*packp.ReportStatus, error) { url := "" @@ -196,7 +196,7 @@ func (s *SendPackSuite) sendPackNoCheck(c *C, ep transport.Endpoint, ep.String(), url, callAdvertisedReferences, ) - r, err := s.Client.NewSendPackSession(ep) + r, err := s.Client.NewReceivePackSession(ep) c.Assert(err, IsNil, comment) defer func() { c.Assert(r.Close(), IsNil, comment) }() @@ -213,10 +213,10 @@ func (s *SendPackSuite) sendPackNoCheck(c *C, ep transport.Endpoint, req.Packfile = s.emptyPackfile() } - return r.SendPack(req) + return r.ReceivePack(req) } -func (s *SendPackSuite) sendPack(c *C, ep transport.Endpoint, +func (s *ReceivePackSuite) receivePack(c *C, ep transport.Endpoint, req *packp.ReferenceUpdateRequest, fixture *fixtures.Fixture, callAdvertisedReferences bool) { @@ -229,7 +229,7 @@ func (s *SendPackSuite) sendPack(c *C, ep transport.Endpoint, "failed with ep=%s fixture=%s callAdvertisedReferences=%s", ep.String(), url, callAdvertisedReferences, ) - report, err := s.sendPackNoCheck(c, ep, req, fixture, callAdvertisedReferences) + report, err := s.receivePackNoCheck(c, ep, req, fixture, callAdvertisedReferences) c.Assert(err, IsNil, comment) if req.Capabilities.Supports(capability.ReportStatus) { @@ -240,14 +240,14 @@ func (s *SendPackSuite) sendPack(c *C, ep transport.Endpoint, } } -func (s *SendPackSuite) checkRemoteHead(c *C, ep transport.Endpoint, head plumbing.Hash) { +func (s *ReceivePackSuite) checkRemoteHead(c *C, ep transport.Endpoint, head plumbing.Hash) { s.checkRemoteReference(c, ep, "refs/heads/master", head) } -func (s *SendPackSuite) checkRemoteReference(c *C, ep transport.Endpoint, +func (s *ReceivePackSuite) checkRemoteReference(c *C, ep transport.Endpoint, refName string, head plumbing.Hash) { - r, err := s.Client.NewFetchPackSession(ep) + r, err := s.Client.NewUploadPackSession(ep) c.Assert(err, IsNil) defer func() { c.Assert(r.Close(), IsNil) }() ar, err := r.AdvertisedReferences() @@ -261,13 +261,13 @@ func (s *SendPackSuite) checkRemoteReference(c *C, ep transport.Endpoint, } } -func (s *SendPackSuite) TestSendPackAddDeleteReference(c *C) { +func (s *ReceivePackSuite) TestSendPackAddDeleteReference(c *C) { s.testSendPackAddReference(c) s.testSendPackDeleteReference(c) } -func (s *SendPackSuite) testSendPackAddReference(c *C) { - r, err := s.Client.NewSendPackSession(s.Endpoint) +func (s *ReceivePackSuite) testSendPackAddReference(c *C) { + r, err := s.Client.NewReceivePackSession(s.Endpoint) c.Assert(err, IsNil) defer func() { c.Assert(r.Close(), IsNil) }() @@ -284,12 +284,12 @@ func (s *SendPackSuite) testSendPackAddReference(c *C) { req.Capabilities.Set(capability.ReportStatus) } - s.sendPack(c, s.Endpoint, req, nil, false) + s.receivePack(c, s.Endpoint, req, nil, false) s.checkRemoteReference(c, s.Endpoint, "refs/heads/newbranch", fixture.Head) } -func (s *SendPackSuite) testSendPackDeleteReference(c *C) { - r, err := s.Client.NewSendPackSession(s.Endpoint) +func (s *ReceivePackSuite) testSendPackDeleteReference(c *C) { + r, err := s.Client.NewReceivePackSession(s.Endpoint) c.Assert(err, IsNil) defer func() { c.Assert(r.Close(), IsNil) }() @@ -306,11 +306,11 @@ func (s *SendPackSuite) testSendPackDeleteReference(c *C) { req.Capabilities.Set(capability.ReportStatus) } - s.sendPack(c, s.Endpoint, req, nil, false) + s.receivePack(c, s.Endpoint, req, nil, false) s.checkRemoteReference(c, s.Endpoint, "refs/heads/newbranch", plumbing.ZeroHash) } -func (s *SendPackSuite) emptyPackfile() io.ReadCloser { +func (s *ReceivePackSuite) emptyPackfile() io.ReadCloser { var buf bytes.Buffer e := packfile.NewEncoder(&buf, memory.NewStorage(), false) _, err := e.Encode(nil) diff --git a/plumbing/transport/test/fetch_pack.go b/plumbing/transport/test/upload_pack.go index 2984154..5af4b29 100644 --- a/plumbing/transport/test/fetch_pack.go +++ b/plumbing/transport/test/upload_pack.go @@ -18,39 +18,39 @@ import ( "gopkg.in/src-d/go-git.v4/plumbing/protocol/packp/capability" ) -type FetchPackSuite struct { +type UploadPackSuite struct { Endpoint transport.Endpoint EmptyEndpoint transport.Endpoint NonExistentEndpoint transport.Endpoint - Client transport.Client + Client transport.Transport } -func (s *FetchPackSuite) TestInfoEmpty(c *C) { - r, err := s.Client.NewFetchPackSession(s.EmptyEndpoint) +func (s *UploadPackSuite) TestAdvertisedReferencesEmpty(c *C) { + r, err := s.Client.NewUploadPackSession(s.EmptyEndpoint) c.Assert(err, IsNil) - info, err := r.AdvertisedReferences() + ar, err := r.AdvertisedReferences() c.Assert(err, Equals, transport.ErrEmptyRemoteRepository) - c.Assert(info, IsNil) + c.Assert(ar, IsNil) } -func (s *FetchPackSuite) TestInfoNotExists(c *C) { - r, err := s.Client.NewFetchPackSession(s.NonExistentEndpoint) +func (s *UploadPackSuite) TestAdvertisedReferencesNotExists(c *C) { + r, err := s.Client.NewUploadPackSession(s.NonExistentEndpoint) c.Assert(err, IsNil) - info, err := r.AdvertisedReferences() + ar, err := r.AdvertisedReferences() c.Assert(err, Equals, transport.ErrRepositoryNotFound) - c.Assert(info, IsNil) + c.Assert(ar, IsNil) - r, err = s.Client.NewFetchPackSession(s.NonExistentEndpoint) + r, err = s.Client.NewUploadPackSession(s.NonExistentEndpoint) c.Assert(err, IsNil) req := packp.NewUploadPackRequest() req.Wants = append(req.Wants, plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) - reader, err := r.FetchPack(req) + reader, err := r.UploadPack(req) c.Assert(err, Equals, transport.ErrRepositoryNotFound) c.Assert(reader, IsNil) } -func (s *FetchPackSuite) TestCallAdvertisedReferenceTwice(c *C) { - r, err := s.Client.NewFetchPackSession(s.Endpoint) +func (s *UploadPackSuite) TestCallAdvertisedReferenceTwice(c *C) { + r, err := s.Client.NewUploadPackSession(s.Endpoint) c.Assert(err, IsNil) ar1, err := r.AdvertisedReferences() c.Assert(err, IsNil) @@ -60,8 +60,8 @@ func (s *FetchPackSuite) TestCallAdvertisedReferenceTwice(c *C) { c.Assert(ar2, DeepEquals, ar1) } -func (s *FetchPackSuite) TestDefaultBranch(c *C) { - r, err := s.Client.NewFetchPackSession(s.Endpoint) +func (s *UploadPackSuite) TestDefaultBranch(c *C) { + r, err := s.Client.NewUploadPackSession(s.Endpoint) c.Assert(err, IsNil) defer func() { c.Assert(r.Close(), IsNil) }() @@ -72,8 +72,8 @@ func (s *FetchPackSuite) TestDefaultBranch(c *C) { c.Assert(symrefs[0], Equals, "HEAD:refs/heads/master") } -func (s *FetchPackSuite) TestAdvertisedReferencesFilterUnsupported(c *C) { - r, err := s.Client.NewFetchPackSession(s.Endpoint) +func (s *UploadPackSuite) TestAdvertisedReferencesFilterUnsupported(c *C) { + r, err := s.Client.NewUploadPackSession(s.Endpoint) c.Assert(err, IsNil) defer func() { c.Assert(r.Close(), IsNil) }() @@ -82,8 +82,8 @@ func (s *FetchPackSuite) TestAdvertisedReferencesFilterUnsupported(c *C) { c.Assert(info.Capabilities.Supports(capability.MultiACK), Equals, false) } -func (s *FetchPackSuite) TestCapabilities(c *C) { - r, err := s.Client.NewFetchPackSession(s.Endpoint) +func (s *UploadPackSuite) TestCapabilities(c *C) { + r, err := s.Client.NewUploadPackSession(s.Endpoint) c.Assert(err, IsNil) defer func() { c.Assert(r.Close(), IsNil) }() @@ -92,8 +92,8 @@ func (s *FetchPackSuite) TestCapabilities(c *C) { c.Assert(info.Capabilities.Get(capability.Agent), HasLen, 1) } -func (s *FetchPackSuite) TestFullFetchPack(c *C) { - r, err := s.Client.NewFetchPackSession(s.Endpoint) +func (s *UploadPackSuite) TestFullUploadPack(c *C) { + r, err := s.Client.NewUploadPackSession(s.Endpoint) c.Assert(err, IsNil) defer func() { c.Assert(r.Close(), IsNil) }() @@ -104,28 +104,28 @@ func (s *FetchPackSuite) TestFullFetchPack(c *C) { req := packp.NewUploadPackRequest() req.Wants = append(req.Wants, plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) - reader, err := r.FetchPack(req) + reader, err := r.UploadPack(req) c.Assert(err, IsNil) s.checkObjectNumber(c, reader, 28) } -func (s *FetchPackSuite) TestFetchPack(c *C) { - r, err := s.Client.NewFetchPackSession(s.Endpoint) +func (s *UploadPackSuite) TestUploadPack(c *C) { + r, err := s.Client.NewUploadPackSession(s.Endpoint) c.Assert(err, IsNil) defer func() { c.Assert(r.Close(), IsNil) }() req := packp.NewUploadPackRequest() req.Wants = append(req.Wants, plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) - reader, err := r.FetchPack(req) + reader, err := r.UploadPack(req) c.Assert(err, IsNil) s.checkObjectNumber(c, reader, 28) } -func (s *FetchPackSuite) TestFetchPackInvalidReq(c *C) { - r, err := s.Client.NewFetchPackSession(s.Endpoint) +func (s *UploadPackSuite) TestUploadPackInvalidReq(c *C) { + r, err := s.Client.NewUploadPackSession(s.Endpoint) c.Assert(err, IsNil) defer func() { c.Assert(r.Close(), IsNil) }() @@ -134,12 +134,12 @@ func (s *FetchPackSuite) TestFetchPackInvalidReq(c *C) { req.Capabilities.Set(capability.Sideband) req.Capabilities.Set(capability.Sideband64k) - _, err = r.FetchPack(req) + _, err = r.UploadPack(req) c.Assert(err, NotNil) } -func (s *FetchPackSuite) TestFetchPackNoChanges(c *C) { - r, err := s.Client.NewFetchPackSession(s.Endpoint) +func (s *UploadPackSuite) TestUploadPackNoChanges(c *C) { + r, err := s.Client.NewUploadPackSession(s.Endpoint) c.Assert(err, IsNil) defer func() { c.Assert(r.Close(), IsNil) }() @@ -147,13 +147,13 @@ func (s *FetchPackSuite) TestFetchPackNoChanges(c *C) { req.Wants = append(req.Wants, plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) req.Haves = append(req.Haves, plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) - reader, err := r.FetchPack(req) + reader, err := r.UploadPack(req) c.Assert(err, Equals, transport.ErrEmptyUploadPackRequest) c.Assert(reader, IsNil) } -func (s *FetchPackSuite) TestFetchPackMulti(c *C) { - r, err := s.Client.NewFetchPackSession(s.Endpoint) +func (s *UploadPackSuite) TestUploadPackMulti(c *C) { + r, err := s.Client.NewUploadPackSession(s.Endpoint) c.Assert(err, IsNil) defer func() { c.Assert(r.Close(), IsNil) }() @@ -161,28 +161,28 @@ func (s *FetchPackSuite) TestFetchPackMulti(c *C) { req.Wants = append(req.Wants, plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")) req.Wants = append(req.Wants, plumbing.NewHash("e8d3ffab552895c19b9fcf7aa264d277cde33881")) - reader, err := r.FetchPack(req) + reader, err := r.UploadPack(req) c.Assert(err, IsNil) s.checkObjectNumber(c, reader, 31) } -func (s *FetchPackSuite) TestFetchError(c *C) { - r, err := s.Client.NewFetchPackSession(s.Endpoint) +func (s *UploadPackSuite) TestFetchError(c *C) { + r, err := s.Client.NewUploadPackSession(s.Endpoint) c.Assert(err, IsNil) req := packp.NewUploadPackRequest() req.Wants = append(req.Wants, plumbing.NewHash("1111111111111111111111111111111111111111")) - reader, err := r.FetchPack(req) - c.Assert(err, Equals, transport.ErrEmptyUploadPackRequest) + reader, err := r.UploadPack(req) + c.Assert(err, NotNil) c.Assert(reader, IsNil) //XXX: We do not test Close error, since implementations might return // different errors if a previous error was found. } -func (s *FetchPackSuite) checkObjectNumber(c *C, r io.Reader, n int) { +func (s *UploadPackSuite) checkObjectNumber(c *C, r io.Reader, n int) { b, err := ioutil.ReadAll(r) c.Assert(err, IsNil) buf := bytes.NewBuffer(b) |