aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/protocol/packp/shallowupd_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-12-06 15:46:09 +0100
committerGitHub <noreply@github.com>2016-12-06 15:46:09 +0100
commit22fe81f342538ae51442a72356036768f7f1a2f9 (patch)
treeccfe9fcd48d3c8f349b42413f71f26ba23a4cba9 /plumbing/protocol/packp/shallowupd_test.go
parent4b5849db76905830e0124b6b9f4294ee13308e0f (diff)
downloadgo-git-22fe81f342538ae51442a72356036768f7f1a2f9.tar.gz
protocol/packp: UploadPackResponse implementation (#161)
* plumbing/protocol: paktp avoid duplication of haves, wants and shallow * protocol/pakp: UploadPackResponse implementation * changes * changes * changes * debug * changes
Diffstat (limited to 'plumbing/protocol/packp/shallowupd_test.go')
-rw-r--r--plumbing/protocol/packp/shallowupd_test.go63
1 files changed, 63 insertions, 0 deletions
diff --git a/plumbing/protocol/packp/shallowupd_test.go b/plumbing/protocol/packp/shallowupd_test.go
new file mode 100644
index 0000000..d64fb5d
--- /dev/null
+++ b/plumbing/protocol/packp/shallowupd_test.go
@@ -0,0 +1,63 @@
+package packp
+
+import (
+ "bytes"
+
+ "gopkg.in/src-d/go-git.v4/plumbing"
+
+ . "gopkg.in/check.v1"
+)
+
+type ShallowUpdateSuite struct{}
+
+var _ = Suite(&ShallowUpdateSuite{})
+
+func (s *ShallowUpdateSuite) TestDecode(c *C) {
+ raw := "" +
+ "0034shallow aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
+ "0034shallow bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" +
+ "0000"
+
+ su := &ShallowUpdate{}
+ err := su.Decode(bytes.NewBufferString(raw))
+ c.Assert(err, IsNil)
+
+ plumbing.HashesSort(su.Shallows)
+
+ c.Assert(su.Unshallows, HasLen, 0)
+ c.Assert(su.Shallows, HasLen, 2)
+ c.Assert(su.Shallows, DeepEquals, []plumbing.Hash{
+ plumbing.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
+ plumbing.NewHash("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"),
+ })
+}
+
+func (s *ShallowUpdateSuite) TestDecodeUnshallow(c *C) {
+ raw := "" +
+ "0036unshallow aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
+ "0036unshallow bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" +
+ "0000"
+
+ su := &ShallowUpdate{}
+ err := su.Decode(bytes.NewBufferString(raw))
+ c.Assert(err, IsNil)
+
+ plumbing.HashesSort(su.Unshallows)
+
+ c.Assert(su.Shallows, HasLen, 0)
+ c.Assert(su.Unshallows, HasLen, 2)
+ c.Assert(su.Unshallows, DeepEquals, []plumbing.Hash{
+ plumbing.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
+ plumbing.NewHash("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"),
+ })
+}
+
+func (s *ShallowUpdateSuite) TestDecodeMalformed(c *C) {
+ raw := "" +
+ "0035unshallow aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
+ "0000"
+
+ su := &ShallowUpdate{}
+ err := su.Decode(bytes.NewBufferString(raw))
+ c.Assert(err, NotNil)
+}