aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/protocol/packp/advrefs_decode_test.go
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2016-12-05 11:59:00 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-12-05 11:59:00 +0100
commit19f59e782b92d32cc430619c77053c764a3180f9 (patch)
tree4fc53ecba70661b2ecafea90d5f72440ad4b8b2b /plumbing/protocol/packp/advrefs_decode_test.go
parent6996381ae43936e7365395e90c8f93372e49be9f (diff)
downloadgo-git-19f59e782b92d32cc430619c77053c764a3180f9.tar.gz
protocol/packp: improve AdvRefs tests (#157)
* protocol/packp: fix Example* func names for AdvRefs. * protocol/packp: test AdvRefs Encode/Decode, no internal functions.
Diffstat (limited to 'plumbing/protocol/packp/advrefs_decode_test.go')
-rw-r--r--plumbing/protocol/packp/advrefs_decode_test.go33
1 files changed, 8 insertions, 25 deletions
diff --git a/plumbing/protocol/packp/advrefs_decode_test.go b/plumbing/protocol/packp/advrefs_decode_test.go
index 82a05a4..f807f15 100644
--- a/plumbing/protocol/packp/advrefs_decode_test.go
+++ b/plumbing/protocol/packp/advrefs_decode_test.go
@@ -17,38 +17,27 @@ type AdvRefsDecodeSuite struct{}
var _ = Suite(&AdvRefsDecodeSuite{})
func (s *AdvRefsDecodeSuite) TestEmpty(c *C) {
- ar := NewAdvRefs()
var buf bytes.Buffer
- d := newAdvRefsDecoder(&buf)
-
- err := d.Decode(ar)
- c.Assert(err, Equals, ErrEmptyAdvRefs)
+ ar := NewAdvRefs()
+ c.Assert(ar.Decode(&buf), Equals, ErrEmptyAdvRefs)
}
func (s *AdvRefsDecodeSuite) TestEmptyFlush(c *C) {
- ar := NewAdvRefs()
var buf bytes.Buffer
e := pktline.NewEncoder(&buf)
e.Flush()
-
- d := newAdvRefsDecoder(&buf)
-
- err := d.Decode(ar)
- c.Assert(err, Equals, ErrEmptyAdvRefs)
+ ar := NewAdvRefs()
+ c.Assert(ar.Decode(&buf), Equals, ErrEmptyAdvRefs)
}
func (s *AdvRefsDecodeSuite) TestEmptyPrefixFlush(c *C) {
- ar := NewAdvRefs()
var buf bytes.Buffer
e := pktline.NewEncoder(&buf)
e.EncodeString("# service=git-upload-pack")
e.Flush()
e.Flush()
-
- d := newAdvRefsDecoder(&buf)
-
- err := d.Decode(ar)
- c.Assert(err, Equals, ErrEmptyAdvRefs)
+ ar := NewAdvRefs()
+ c.Assert(ar.Decode(&buf), Equals, ErrEmptyAdvRefs)
}
func (s *AdvRefsDecodeSuite) TestShortForHash(c *C) {
@@ -62,10 +51,7 @@ func (s *AdvRefsDecodeSuite) TestShortForHash(c *C) {
func (s *AdvRefsDecodeSuite) testDecoderErrorMatches(c *C, input io.Reader, pattern string) {
ar := NewAdvRefs()
- d := newAdvRefsDecoder(input)
-
- err := d.Decode(ar)
- c.Assert(err, ErrorMatches, pattern)
+ c.Assert(ar.Decode(input), ErrorMatches, pattern)
}
func (s *AdvRefsDecodeSuite) TestInvalidFirstHash(c *C) {
@@ -93,10 +79,7 @@ func (s *AdvRefsDecodeSuite) testDecodeOK(c *C, payloads []string) *AdvRefs {
c.Assert(err, IsNil)
ar := NewAdvRefs()
- d := newAdvRefsDecoder(&buf)
-
- err = d.Decode(ar)
- c.Assert(err, IsNil)
+ c.Assert(ar.Decode(&buf), IsNil)
return ar
}