| 47 | } |
| 48 | |
| 49 | func (s *PatchSuite) TestFileStatsString(c *C) { |
| 50 | testCases := []struct { |
| 51 | description string |
| 52 | input FileStats |
| 53 | expected string |
| 54 | }{ |
| 55 | |
| 56 | { |
| 57 | description: "no files changed", |
| 58 | input: []FileStat{}, |
| 59 | expected: "", |
| 60 | }, |
| 61 | { |
| 62 | description: "one file touched - no changes", |
| 63 | input: []FileStat{ |
| 64 | { |
| 65 | Name: "file1", |
| 66 | }, |
| 67 | }, |
| 68 | expected: " file1 | 0 \n", |
| 69 | }, |
| 70 | { |
| 71 | description: "one file changed", |
| 72 | input: []FileStat{ |
| 73 | { |
| 74 | Name: "file1", |
| 75 | Addition: 1, |
| 76 | }, |
| 77 | }, |
| 78 | expected: " file1 | 1 +\n", |
| 79 | }, |
| 80 | { |
| 81 | description: "one file changed with one addition and one deletion", |
| 82 | input: []FileStat{ |
| 83 | { |
| 84 | Name: ".github/workflows/git.yml", |
| 85 | Addition: 1, |
| 86 | Deletion: 1, |
| 87 | }, |
| 88 | }, |
| 89 | expected: " .github/workflows/git.yml | 2 +-\n", |
| 90 | }, |
| 91 | { |
| 92 | description: "two files changed", |
| 93 | input: []FileStat{ |
| 94 | { |
| 95 | Name: ".github/workflows/git.yml", |
| 96 | Addition: 1, |
| 97 | Deletion: 1, |
| 98 | }, |
| 99 | { |
| 100 | Name: "cli/go-git/go.mod", |
| 101 | Addition: 4, |
| 102 | Deletion: 4, |
| 103 | }, |
| 104 | }, |
| 105 | expected: " .github/workflows/git.yml | 2 +-\n cli/go-git/go.mod | 8 ++++----\n", |
| 106 | }, |