diff options
author | Alberto Cortés <alcortesm@gmail.com> | 2016-10-26 17:56:26 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-10-26 15:56:26 +0000 |
commit | 73fa9ef25a8af9c8337a4cf34a67cfe208f1a7c5 (patch) | |
tree | 66886d9b47e373b748c1bceafe1885e6f47868dd /clients/common/common_test.go | |
parent | f3ab3a6c73015b5ae9b2a4756dc646e1211cedb9 (diff) | |
download | go-git-73fa9ef25a8af9c8337a4cf34a67cfe208f1a7c5.tar.gz |
Use advrefs in gituploadpackinfo (#92)
* add advrefs encoder and parser
* modify advrefs encoder to resemble json encoder
* turn advrefs parser into a decoder
* clean code
* improve documentation
* improve documentation
* clean code
* upgrade to new pktline.Add and add Flush const to easy integration
* gometalinter
* Use packp/advrefs for GitUploadPackInfo parsing
- GitUploadPackInfo now uses packp/advrefs instead of parsing the
message by itself.
- Capabilities has been moved from clients/common to packp to avoid a
circular import.
- Cleaning of advrefs_test code.
- Add support for prefix encoding and decoding in advrefs.
* clean advrefs test code
* clean advrefs test code
* clean advrefs test code
* gometalinter
* add pktline encoder
* change pktline.EncodeFlush to pktline.Flush
* make scanner tests use the encoder instead of Pktlines
* check errors on flush and clean constants
* ubstitute the PktLines type with a pktline.Encoder
* use pktline.Encoder in all go-git
* add example of pktline.Encodef()
* add package overview
* documentation
* support symbolic links other than HEAD
* simplify decoding of shallows
* packp: fix mcuadros comments
- all abbreviates removed (by visual inspection, some may remain)
- all empty maps are initialized using make
- simplify readRef with a switch
- make decodeShallow malformed error more verbose
- add pktline.Encoder.encodeLine
- remove infamous panic in checkPayloadLength by refactoring out
the whole function
Diffstat (limited to 'clients/common/common_test.go')
-rw-r--r-- | clients/common/common_test.go | 43 |
1 files changed, 5 insertions, 38 deletions
diff --git a/clients/common/common_test.go b/clients/common/common_test.go index 66a49e1..5809584 100644 --- a/clients/common/common_test.go +++ b/clients/common/common_test.go @@ -6,7 +6,7 @@ import ( "testing" "gopkg.in/src-d/go-git.v4/core" - "gopkg.in/src-d/go-git.v4/formats/packp/pktline" + "gopkg.in/src-d/go-git.v4/formats/packp" . "gopkg.in/check.v1" ) @@ -38,7 +38,7 @@ func (s *SuiteCommon) TestNewEndpointWrongForgat(c *C) { const CapabilitiesFixture = "6ecf0ef2c2dffb796033e5a02219af86ec6584e5 HEADmulti_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag multi_ack_detailed no-done symref=HEAD:refs/heads/master agent=git/2:2.4.8~dbussink-fix-enterprise-tokens-compilation-1167-gc7006cf" func (s *SuiteCommon) TestCapabilitiesSymbolicReference(c *C) { - cap := NewCapabilities() + cap := packp.NewCapabilities() cap.Decode(CapabilitiesFixture) c.Assert(cap.SymbolicReference("HEAD"), Equals, "refs/heads/master") } @@ -49,7 +49,7 @@ func (s *SuiteCommon) TestGitUploadPackInfo(c *C) { b, _ := base64.StdEncoding.DecodeString(GitUploadPackInfoFixture) i := NewGitUploadPackInfo() - err := i.Decode(pktline.NewScanner(bytes.NewBuffer(b))) + err := i.Decode(bytes.NewBuffer(b)) c.Assert(err, IsNil) name := i.Capabilities.SymbolicReference("HEAD") @@ -71,7 +71,7 @@ func (s *SuiteCommon) TestGitUploadPackInfoNoHEAD(c *C) { b, _ := base64.StdEncoding.DecodeString(GitUploadPackInfoNoHEADFixture) i := NewGitUploadPackInfo() - err := i.Decode(pktline.NewScanner(bytes.NewBuffer(b))) + err := i.Decode(bytes.NewBuffer(b)) c.Assert(err, IsNil) name := i.Capabilities.SymbolicReference("HEAD") @@ -87,43 +87,10 @@ func (s *SuiteCommon) TestGitUploadPackInfoEmpty(c *C) { b := bytes.NewBuffer(nil) i := NewGitUploadPackInfo() - err := i.Decode(pktline.NewScanner(b)) + err := i.Decode(b) c.Assert(err, ErrorMatches, "permanent.*empty.*") } -func (s *SuiteCommon) TestCapabilitiesDecode(c *C) { - cap := NewCapabilities() - cap.Decode("symref=foo symref=qux thin-pack") - - c.Assert(cap.m, HasLen, 2) - c.Assert(cap.Get("symref").Values, DeepEquals, []string{"foo", "qux"}) - c.Assert(cap.Get("thin-pack").Values, DeepEquals, []string{""}) -} - -func (s *SuiteCommon) TestCapabilitiesSet(c *C) { - cap := NewCapabilities() - cap.Add("symref", "foo", "qux") - cap.Set("symref", "bar") - - c.Assert(cap.m, HasLen, 1) - c.Assert(cap.Get("symref").Values, DeepEquals, []string{"bar"}) -} - -func (s *SuiteCommon) TestCapabilitiesSetEmpty(c *C) { - cap := NewCapabilities() - cap.Set("foo", "bar") - - c.Assert(cap.Get("foo").Values, HasLen, 1) -} - -func (s *SuiteCommon) TestCapabilitiesAdd(c *C) { - cap := NewCapabilities() - cap.Add("symref", "foo", "qux") - cap.Add("thin-pack") - - c.Assert(cap.String(), Equals, "symref=foo symref=qux thin-pack") -} - func (s *SuiteCommon) TestGitUploadPackEncode(c *C) { info := NewGitUploadPackInfo() info.Capabilities.Add("symref", "HEAD:refs/heads/master") |