(c *C)
| 15 | ) |
| 16 | |
| 17 | func (s *IndexSuite) TestEncode(c *C) { |
| 18 | idx := &Index{ |
| 19 | Version: 2, |
| 20 | Entries: []*Entry{{ |
| 21 | CreatedAt: time.Now(), |
| 22 | ModifiedAt: time.Now(), |
| 23 | Dev: 4242, |
| 24 | Inode: 424242, |
| 25 | UID: 84, |
| 26 | GID: 8484, |
| 27 | Size: 42, |
| 28 | Stage: TheirMode, |
| 29 | Hash: plumbing.NewHash("e25b29c8946e0e192fae2edc1dabf7be71e8ecf3"), |
| 30 | Name: "foo", |
| 31 | }, { |
| 32 | CreatedAt: time.Now(), |
| 33 | ModifiedAt: time.Now(), |
| 34 | Name: "bar", |
| 35 | Size: 82, |
| 36 | }, { |
| 37 | CreatedAt: time.Now(), |
| 38 | ModifiedAt: time.Now(), |
| 39 | Name: strings.Repeat(" ", 20), |
| 40 | Size: 82, |
| 41 | }}, |
| 42 | } |
| 43 | |
| 44 | buf := bytes.NewBuffer(nil) |
| 45 | e := NewEncoder(buf) |
| 46 | err := e.Encode(idx) |
| 47 | c.Assert(err, IsNil) |
| 48 | |
| 49 | output := &Index{} |
| 50 | d := NewDecoder(buf) |
| 51 | err = d.Decode(output) |
| 52 | c.Assert(err, IsNil) |
| 53 | |
| 54 | c.Assert(cmp.Equal(idx, output), Equals, true) |
| 55 | |
| 56 | c.Assert(output.Entries[0].Name, Equals, strings.Repeat(" ", 20)) |
| 57 | c.Assert(output.Entries[1].Name, Equals, "bar") |
| 58 | c.Assert(output.Entries[2].Name, Equals, "foo") |
| 59 | } |
| 60 | |
| 61 | func TestEncodeLongName(t *testing.T) { |
| 62 | t.Parallel() |
nothing calls this directly
no test coverage detected