aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/protocol/packp/updreq_encode_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'plumbing/protocol/packp/updreq_encode_test.go')
-rw-r--r--plumbing/protocol/packp/updreq_encode_test.go30
1 files changed, 29 insertions, 1 deletions
diff --git a/plumbing/protocol/packp/updreq_encode_test.go b/plumbing/protocol/packp/updreq_encode_test.go
index 5ad2b1b..6ba0043 100644
--- a/plumbing/protocol/packp/updreq_encode_test.go
+++ b/plumbing/protocol/packp/updreq_encode_test.go
@@ -5,9 +5,11 @@ import (
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/format/pktline"
+ "github.com/go-git/go-git/v5/plumbing/protocol/packp/capability"
- . "gopkg.in/check.v1"
"io/ioutil"
+
+ . "gopkg.in/check.v1"
)
type UpdReqEncodeSuite struct{}
@@ -142,3 +144,29 @@ func (s *UpdReqEncodeSuite) TestWithPackfile(c *C) {
s.testEncode(c, r, expected)
}
+
+func (s *UpdReqEncodeSuite) TestPushOptions(c *C) {
+ hash1 := plumbing.NewHash("1ecf0ef2c2dffb796033e5a02219af86ec6584e5")
+ hash2 := plumbing.NewHash("2ecf0ef2c2dffb796033e5a02219af86ec6584e5")
+ name := plumbing.ReferenceName("myref")
+
+ r := NewReferenceUpdateRequest()
+ r.Capabilities.Set(capability.PushOptions)
+ r.Commands = []*Command{
+ {Name: name, Old: hash1, New: hash2},
+ }
+ r.Options = []*Option{
+ {Key: "SomeKey", Value: "SomeValue"},
+ {Key: "AnotherKey", Value: "AnotherValue"},
+ }
+
+ expected := pktlines(c,
+ "1ecf0ef2c2dffb796033e5a02219af86ec6584e5 2ecf0ef2c2dffb796033e5a02219af86ec6584e5 myref\x00push-options",
+ pktline.FlushString,
+ "SomeKey=SomeValue",
+ "AnotherKey=AnotherValue",
+ pktline.FlushString,
+ )
+
+ s.testEncode(c, r, expected)
+}