(t *testing.T)
| 109 | } |
| 110 | |
| 111 | func TestScanPreviousVersions(t *testing.T) { |
| 112 | repo := test.NewRepo(t) |
| 113 | repo.Pushd() |
| 114 | defer func() { |
| 115 | repo.Popd() |
| 116 | repo.Cleanup() |
| 117 | }() |
| 118 | |
| 119 | now := time.Now() |
| 120 | |
| 121 | inputs := []*test.CommitInput{ |
| 122 | { // 0 |
| 123 | CommitDate: now.AddDate(0, 0, -20), |
| 124 | Files: []*test.FileInput{ |
| 125 | {Filename: "file1.txt", Size: 20}, |
| 126 | {Filename: "file2.txt", Size: 30}, |
| 127 | {Filename: "folder/nested.txt", Size: 40}, |
| 128 | {Filename: "folder/nested2.txt", Size: 31}, |
| 129 | }, |
| 130 | }, |
| 131 | { // 1 |
| 132 | CommitDate: now.AddDate(0, 0, -10), |
| 133 | Files: []*test.FileInput{ |
| 134 | {Filename: "file2.txt", Size: 22}, |
| 135 | }, |
| 136 | }, |
| 137 | { // 2 |
| 138 | NewBranch: "excluded", |
| 139 | CommitDate: now.AddDate(0, 0, -6), |
| 140 | Files: []*test.FileInput{ |
| 141 | {Filename: "file2.txt", Size: 12}, |
| 142 | {Filename: "folder/nested2.txt", Size: 16}, |
| 143 | }, |
| 144 | }, |
| 145 | { // 3 |
| 146 | ParentBranches: []string{"master"}, |
| 147 | CommitDate: now.AddDate(0, 0, -4), |
| 148 | Files: []*test.FileInput{ |
| 149 | {Filename: "folder/nested.txt", Size: 42}, |
| 150 | {Filename: "folder/nested2.txt", Size: 6}, |
| 151 | }, |
| 152 | }, |
| 153 | { // 4 |
| 154 | Files: []*test.FileInput{ |
| 155 | {Filename: "folder/nested.txt", Size: 22}, |
| 156 | }, |
| 157 | }, |
| 158 | } |
| 159 | outputs := repo.AddCommits(inputs) |
| 160 | |
| 161 | // Previous commits excludes final state of each file, which is: |
| 162 | // file1.txt [0] (unchanged since first commit so excluded) |
| 163 | // file2.txt [1] (because [2] is on another branch so excluded) |
| 164 | // folder/nested.txt [4] (updated at last commit) |
| 165 | // folder/nested2.txt [3] |
| 166 | |
| 167 | // The only changes which will be included are changes prior to final state |
| 168 | // where the '-' side of the diff is inside the date range |
nothing calls this directly
no test coverage detected