aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/protocol/packp/srvresp_test.go
diff options
context:
space:
mode:
authorPaulo Gomes <pjbgf@linux.com>2023-10-07 18:44:31 +0100
committerPaulo Gomes <pjbgf@linux.com>2023-10-07 18:44:31 +0100
commit1d26511c717ea334a16499a018d2b877b557be79 (patch)
treefbf1be6db06f715045a31cf0d52cb82c7405ad66 /plumbing/protocol/packp/srvresp_test.go
parent19fe126d8889134e6224717a756745eed9985e22 (diff)
downloadgo-git-1d26511c717ea334a16499a018d2b877b557be79.tar.gz
plumbing: protocol/packp, Add validation for decodeLine
Signed-off-by: Paulo Gomes <pjbgf@linux.com>
Diffstat (limited to 'plumbing/protocol/packp/srvresp_test.go')
-rw-r--r--plumbing/protocol/packp/srvresp_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/plumbing/protocol/packp/srvresp_test.go b/plumbing/protocol/packp/srvresp_test.go
index aa0af52..b7270e7 100644
--- a/plumbing/protocol/packp/srvresp_test.go
+++ b/plumbing/protocol/packp/srvresp_test.go
@@ -3,6 +3,7 @@ package packp
import (
"bufio"
"bytes"
+ "fmt"
"github.com/go-git/go-git/v5/plumbing"
@@ -23,6 +24,32 @@ func (s *ServerResponseSuite) TestDecodeNAK(c *C) {
c.Assert(sr.ACKs, HasLen, 0)
}
+func (s *ServerResponseSuite) TestDecodeNewLine(c *C) {
+ raw := "\n"
+
+ sr := &ServerResponse{}
+ err := sr.Decode(bufio.NewReader(bytes.NewBufferString(raw)), false)
+ c.Assert(err, NotNil)
+ c.Assert(err.Error(), Equals, "invalid pkt-len found")
+}
+
+func (s *ServerResponseSuite) TestDecodeEmpty(c *C) {
+ raw := ""
+
+ sr := &ServerResponse{}
+ err := sr.Decode(bufio.NewReader(bytes.NewBufferString(raw)), false)
+ c.Assert(err, IsNil)
+}
+
+func (s *ServerResponseSuite) TestDecodePartial(c *C) {
+ raw := "000600\n"
+
+ sr := &ServerResponse{}
+ err := sr.Decode(bufio.NewReader(bytes.NewBufferString(raw)), false)
+ c.Assert(err, NotNil)
+ c.Assert(err.Error(), Equals, fmt.Sprintf("unexpected content %q", "00"))
+}
+
func (s *ServerResponseSuite) TestDecodeACK(c *C) {
raw := "0031ACK 6ecf0ef2c2dffb796033e5a02219af86ec6584e5\n"