| 1 |
package file |
| 2 |
|
| 3 |
import ( |
| 4 |
"os" |
| 5 |
|
| 6 |
"github.com/go-git/go-git/v5/plumbing/transport/test" |
| 7 |
|
| 8 |
fixtures "github.com/go-git/go-git-fixtures/v4" |
| 9 |
. "gopkg.in/check.v1" |
| 10 |
) |
| 11 |
|
| 12 |
type ReceivePackSuite struct { |
| 13 |
CommonSuite |
| 14 |
test.ReceivePackSuite |
| 15 |
} |
| 16 |
|
| 17 |
var _ = Suite(&ReceivePackSuite{}) |
| 18 |
|
| 19 |
func (s *ReceivePackSuite) SetUpSuite(c *C) { |
| 20 |
s.CommonSuite.SetUpSuite(c) |
| 21 |
s.ReceivePackSuite.Client = DefaultClient |
| 22 |
} |
| 23 |
|
| 24 |
func (s *ReceivePackSuite) SetUpTest(c *C) { |
| 25 |
fixture := fixtures.Basic().One() |
| 26 |
path := fixture.DotGit().Root() |
| 27 |
s.Endpoint = prepareRepo(c, path) |
| 28 |
|
| 29 |
fixture = fixtures.ByTag("empty").One() |
| 30 |
path = fixture.DotGit().Root() |
| 31 |
s.EmptyEndpoint = prepareRepo(c, path) |
| 32 |
|
| 33 |
s.NonExistentEndpoint = prepareRepo(c, "/non-existent") |
| 34 |
} |
| 35 |
|
| 36 |
func (s *ReceivePackSuite) TearDownTest(c *C) { |
| 37 |
s.Suite.TearDownSuite(c) |
| 38 |
} |
| 39 |
|
| 40 |
// TODO: fix test |
| 41 |
func (s *ReceivePackSuite) TestCommandNoOutput(c *C) { |
| 42 |
c.Skip("failing test") |
| 43 |
|
| 44 |
if _, err := os.Stat("/bin/true"); os.IsNotExist(err) { |
| 45 |
c.Skip("/bin/true not found") |
| 46 |
} |
| 47 |
|
| 48 |
client := NewClient("true", "true") |
| 49 |
session, err := client.NewReceivePackSession(s.Endpoint, s.EmptyAuth) |
| 50 |
c.Assert(err, IsNil) |
| 51 |
ar, err := session.AdvertisedReferences() |
| 52 |
c.Assert(err, IsNil) |
| 53 |
c.Assert(ar, IsNil) |
| 54 |
} |
| 55 |
|
| 56 |
func (s *ReceivePackSuite) TestMalformedInputNoErrors(c *C) { |
| 57 |
if _, err := os.Stat("/usr/bin/yes"); os.IsNotExist(err) { |
| 58 |
c.Skip("/usr/bin/yes not found") |
| 59 |
} |
| 60 |
|
| 61 |
client := NewClient("yes", "yes") |
| 62 |
session, err := client.NewReceivePackSession(s.Endpoint, s.EmptyAuth) |
| 63 |
c.Assert(err, IsNil) |
| 64 |
ar, err := session.AdvertisedReferences() |
| 65 |
c.Assert(err, NotNil) |
| 66 |
c.Assert(ar, IsNil) |
| 67 |
} |
| 68 |
|
| 69 |
func (s *ReceivePackSuite) TestNonExistentCommand(c *C) { |
| 70 |
cmd := "/non-existent-git" |
| 71 |
client := NewClient(cmd, cmd) |
| 72 |
session, err := client.NewReceivePackSession(s.Endpoint, s.EmptyAuth) |
| 73 |
c.Assert(err, ErrorMatches, ".*(no such file or directory.*|.*file does not exist)*.") |
| 74 |
c.Assert(session, IsNil) |
| 75 |
} |