MCPcopy Create free account
hub / github.com/antonmedv/gitmal / TestParseNextFileHeader

Function TestParseNextFileHeader

pkg/gitdiff/parser_test.go:230–335  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

228}
229
230func TestParseNextFileHeader(t *testing.T) {
231 tests := map[string]struct {
232 Input string
233 Output *File
234 Preamble string
235 Err bool
236 }{
237 "gitHeader": {
238 Input: `commit 1acbae563cd6ef5750a82ee64e116c6eb065cb94
239Author: Morton Haypenny <mhaypenny@example.com>
240Date: Tue Apr 2 22:30:00 2019 -0700
241
242 This is a sample commit message.
243
244diff --git a/file.txt b/file.txt
245index cc34da1..1acbae5 100644
246--- a/file.txt
247+++ b/file.txt
248@@ -1,3 +1,4 @@
249`,
250 Output: &File{
251 OldName: "file.txt",
252 NewName: "file.txt",
253 OldMode: os.FileMode(0100644),
254 OldOIDPrefix: "cc34da1",
255 NewOIDPrefix: "1acbae5",
256 },
257 Preamble: `commit 1acbae563cd6ef5750a82ee64e116c6eb065cb94
258Author: Morton Haypenny <mhaypenny@example.com>
259Date: Tue Apr 2 22:30:00 2019 -0700
260
261 This is a sample commit message.
262
263`,
264 },
265 "traditionalHeader": {
266 Input: `
267--- file.txt 2019-04-01 22:58:14.833597918 -0700
268+++ file.txt 2019-04-01 22:58:14.833597918 -0700
269@@ -1,3 +1,4 @@
270`,
271 Output: &File{
272 OldName: "file.txt",
273 NewName: "file.txt",
274 },
275 Preamble: "\n",
276 },
277 "noHeaders": {
278 Input: `
279this is a line
280this is another line
281--- could this be a header?
282nope, it's just some dashes
283`,
284 Output: nil,
285 Preamble: `
286this is a line
287this is another line

Callers

nothing calls this directly

Calls 3

newTestParserFunction · 0.85
ParseNextFileHeaderMethod · 0.80
ErrorfMethod · 0.80

Tested by

no test coverage detected