aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/protocol/packp/updreq_encode_test.go
diff options
context:
space:
mode:
authorSören Bohn <soeren.bohn@ppro.com>2021-10-26 15:49:15 +0200
committerSören Bohn <soeren@lambda-complex.org>2021-10-26 16:08:54 +0200
commite729edb00d36e9bd19f99dfa493984233b0dccfa (patch)
tree3cb555f90071aa32768c6a49a90d52d47eda64be /plumbing/protocol/packp/updreq_encode_test.go
parent99457e570d34320b12fb4fcd0f054f3d0b1d3eec (diff)
downloadgo-git-e729edb00d36e9bd19f99dfa493984233b0dccfa.tar.gz
plumbing: packp, Add encoding for push-options. Fixes #268.
go-git: Add field `Options` to `PushOptions`, wire functionality.
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)
+}