(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestProcessLinesWithMacros(t *testing.T) { |
| 11 | lines, _, err := ParseLines(strings.NewReader(strings.Join([]string{ |
| 12 | "[attr]lfs filter=lfs diff=lfs merge=lfs -text", |
| 13 | "*.dat lfs", |
| 14 | "*.txt text"}, "\n"))) |
| 15 | |
| 16 | assert.Len(t, lines, 3) |
| 17 | assert.NoError(t, err) |
| 18 | |
| 19 | assert.Implements(t, (*MacroLine)(nil), lines[0]) |
| 20 | assert.Implements(t, (*PatternLine)(nil), lines[1]) |
| 21 | assert.Implements(t, (*PatternLine)(nil), lines[2]) |
| 22 | |
| 23 | mp := NewMacroProcessor() |
| 24 | patternLines := mp.ProcessLines(lines, true) |
| 25 | |
| 26 | assert.Len(t, patternLines, 2) |
| 27 | |
| 28 | assert.Implements(t, (*PatternLine)(nil), patternLines[0]) |
| 29 | assert.Implements(t, (*PatternLine)(nil), patternLines[1]) |
| 30 | |
| 31 | assert.Equal(t, patternLines[0].Pattern().String(), "*.dat") |
| 32 | assert.Len(t, patternLines[0].Attrs(), 5) |
| 33 | assert.Equal(t, patternLines[0].Attrs()[0], &Attr{K: "filter", V: "lfs"}) |
| 34 | assert.Equal(t, patternLines[0].Attrs()[1], &Attr{K: "diff", V: "lfs"}) |
| 35 | assert.Equal(t, patternLines[0].Attrs()[2], &Attr{K: "merge", V: "lfs"}) |
| 36 | assert.Equal(t, patternLines[0].Attrs()[3], &Attr{K: "text", V: "false"}) |
| 37 | assert.Equal(t, patternLines[0].Attrs()[4], &Attr{K: "lfs", V: "true"}) |
| 38 | |
| 39 | assert.Equal(t, patternLines[1].Pattern().String(), "*.txt") |
| 40 | assert.Len(t, patternLines[1].Attrs(), 1) |
| 41 | assert.Equal(t, patternLines[1].Attrs()[0], &Attr{K: "text", V: "true"}) |
| 42 | } |
| 43 | |
| 44 | func TestProcessLinesWithMacrosDisabled(t *testing.T) { |
| 45 | lines, _, err := ParseLines(strings.NewReader(strings.Join([]string{ |
nothing calls this directly
no test coverage detected