aboutsummaryrefslogtreecommitdiffstats
path: root/formats/idxfile/encoder_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-09-10 01:16:22 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-09-10 01:16:22 +0200
commite013b297b14949aadaec66deaedc130e86c30afb (patch)
tree481504d00841b97daa1d10de1ca5f780f37e0353 /formats/idxfile/encoder_test.go
parenta98a111780a74fbc1418d8fc8acc852b9d6187d2 (diff)
downloadgo-git-e013b297b14949aadaec66deaedc130e86c30afb.tar.gz
format: idxfile sorted entries
Diffstat (limited to 'formats/idxfile/encoder_test.go')
-rw-r--r--formats/idxfile/encoder_test.go21
1 files changed, 20 insertions, 1 deletions
diff --git a/formats/idxfile/encoder_test.go b/formats/idxfile/encoder_test.go
index 11ecaee..380b8e8 100644
--- a/formats/idxfile/encoder_test.go
+++ b/formats/idxfile/encoder_test.go
@@ -5,6 +5,7 @@ import (
"io/ioutil"
. "gopkg.in/check.v1"
+ "gopkg.in/src-d/go-git.v4/core"
"gopkg.in/src-d/go-git.v4/fixtures"
)
@@ -13,7 +14,25 @@ func (s *IdxfileSuite) SetUpSuite(c *C) {
}
func (s *IdxfileSuite) TestEncode(c *C) {
- fixtures.All().Test(c, func(f *fixtures.Fixture) {
+ expected := &Idxfile{}
+ expected.Add(core.NewHash("4bfc730165c370df4a012afbb45ba3f9c332c0d4"), 82, 82)
+ expected.Add(core.NewHash("8fa2238efdae08d83c12ee176fae65ff7c99af46"), 42, 42)
+
+ buf := bytes.NewBuffer(nil)
+ e := NewEncoder(buf)
+ _, err := e.Encode(expected)
+ c.Assert(err, IsNil)
+
+ idx := &Idxfile{}
+ d := NewDecoder(buf)
+ err = d.Decode(idx)
+ c.Assert(err, IsNil)
+
+ c.Assert(idx.Entries, DeepEquals, expected.Entries)
+}
+
+func (s *IdxfileSuite) TestDecodeEncode(c *C) {
+ fixtures.ByTag("packfile").Test(c, func(f *fixtures.Fixture) {
expected, err := ioutil.ReadAll(f.Idx())
c.Assert(err, IsNil)