MCPcopy
hub / github.com/go-git/go-git / TestEncode

Method TestEncode

plumbing/format/index/encoder_test.go:17–59  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

15)
16
17func (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
61func TestEncodeLongName(t *testing.T) {
62 t.Parallel()

Callers

nothing calls this directly

Calls 5

EncodeMethod · 0.95
DecodeMethod · 0.95
NewHashFunction · 0.92
NewEncoderFunction · 0.70
NewDecoderFunction · 0.70

Tested by

no test coverage detected