(c *C)
| 1008 | } |
| 1009 | |
| 1010 | func (s *SuiteCommit) TestEncodeExtraHeaders(c *C) { |
| 1011 | object := &plumbing.MemoryObject{} |
| 1012 | object.SetType(plumbing.CommitObject) |
| 1013 | object.Write([]byte(`tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 |
| 1014 | author John Doe <john.doe@example.com> 1755280730 -0700 |
| 1015 | committer John Doe <john.doe@example.com> 1755280730 -0700 |
| 1016 | continuedheader to be |
| 1017 | continued |
| 1018 | continuedheader to be |
| 1019 | continued |
| 1020 | on |
| 1021 | more than |
| 1022 | a single line |
| 1023 | simpleflag |
| 1024 | value no key |
| 1025 | |
| 1026 | initial commit |
| 1027 | `)) |
| 1028 | |
| 1029 | commit, err := DecodeCommit(s.Storer, object) |
| 1030 | c.Assert(err, IsNil) |
| 1031 | |
| 1032 | c.Assert(commit.ExtraHeaders, DeepEquals, []ExtraHeader{ |
| 1033 | ExtraHeader{ |
| 1034 | Key: "continuedheader", |
| 1035 | Value: "to be\ncontinued", |
| 1036 | }, |
| 1037 | ExtraHeader{ |
| 1038 | Key: "continuedheader", |
| 1039 | Value: "to be\ncontinued\non\nmore than\na single line", |
| 1040 | }, |
| 1041 | ExtraHeader{ |
| 1042 | Key: "simpleflag", |
| 1043 | Value: "", |
| 1044 | }, |
| 1045 | ExtraHeader{ |
| 1046 | Key: "", |
| 1047 | Value: "value no key", |
| 1048 | }, |
| 1049 | }) |
| 1050 | |
| 1051 | // Similar to TestString since no signature |
| 1052 | encoded := &plumbing.MemoryObject{} |
| 1053 | err = commit.EncodeWithoutSignature(encoded) |
| 1054 | er, err := encoded.Reader() |
| 1055 | c.Assert(err, IsNil) |
| 1056 | payload, err := io.ReadAll(er) |
| 1057 | c.Assert(err, IsNil) |
| 1058 | |
| 1059 | c.Assert(string(payload), Equals, `tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 |
| 1060 | author John Doe <john.doe@example.com> 1755280730 -0700 |
| 1061 | committer John Doe <john.doe@example.com> 1755280730 -0700 |
| 1062 | continuedheader to be |
| 1063 | continued |
| 1064 | continuedheader to be |
| 1065 | continued |
| 1066 | on |
| 1067 | more than |
nothing calls this directly
no test coverage detected