|
1 | 1 | package server_test
|
2 | 2 |
|
3 | 3 | import (
|
| 4 | + "context" |
| 5 | + |
| 6 | + "github.com/go-git/go-git/v5/plumbing" |
| 7 | + "github.com/go-git/go-git/v5/plumbing/protocol/packp" |
4 | 8 | "github.com/go-git/go-git/v5/plumbing/transport"
|
5 | 9 |
|
| 10 | + fixtures "github.com/go-git/go-git-fixtures/v4" |
6 | 11 | . "gopkg.in/check.v1"
|
7 | 12 | )
|
8 | 13 |
|
@@ -31,3 +36,28 @@ func (s *ReceivePackSuite) TestAdvertisedReferencesNotExists(c *C) {
|
31 | 36 | c.Assert(err, Equals, transport.ErrRepositoryNotFound)
|
32 | 37 | c.Assert(r, IsNil)
|
33 | 38 | }
|
| 39 | + |
| 40 | +func (s *ReceivePackSuite) TestReceivePackWithNilPackfile(c *C) { |
| 41 | + endpoint := s.Endpoint |
| 42 | + auth := s.EmptyAuth |
| 43 | + |
| 44 | + fixture := fixtures.Basic().ByTag("packfile").One() |
| 45 | + req := packp.NewReferenceUpdateRequest() |
| 46 | + req.Commands = []*packp.Command{ |
| 47 | + {Name: "refs/heads/newbranch", Old: plumbing.NewHash(fixture.Head), New: plumbing.ZeroHash}, |
| 48 | + } |
| 49 | + // default is already nil, but be explicit since this is what the test is for |
| 50 | + req.Packfile = nil |
| 51 | + |
| 52 | + comment := Commentf( |
| 53 | + "failed with ep=%s fixture=%s", |
| 54 | + endpoint.String(), fixture.URL, |
| 55 | + ) |
| 56 | + |
| 57 | + r, err := s.Client.NewReceivePackSession(endpoint, auth) |
| 58 | + c.Assert(err, IsNil, comment) |
| 59 | + defer func() { c.Assert(r.Close(), IsNil, comment) }() |
| 60 | + |
| 61 | + report, err := r.ReceivePack(context.Background(), req) |
| 62 | + c.Assert(report, IsNil, comment) |
| 63 | +} |
0 commit comments