(t *testing.T)
| 193 | } |
| 194 | |
| 195 | func TestDiffBlobs(t *testing.T) { |
| 196 | t.Parallel() |
| 197 | repo := createTestRepo(t) |
| 198 | defer cleanupTestRepo(t, repo) |
| 199 | |
| 200 | odb, err := repo.Odb() |
| 201 | checkFatal(t, err) |
| 202 | |
| 203 | id1, err := odb.Write([]byte("hello\nhello\n"), ObjectBlob) |
| 204 | checkFatal(t, err) |
| 205 | |
| 206 | id2, err := odb.Write([]byte("hallo\nhallo\n"), ObjectBlob) |
| 207 | checkFatal(t, err) |
| 208 | |
| 209 | blob1, err := repo.LookupBlob(id1) |
| 210 | checkFatal(t, err) |
| 211 | |
| 212 | blob2, err := repo.LookupBlob(id2) |
| 213 | checkFatal(t, err) |
| 214 | |
| 215 | var files, hunks, lines int |
| 216 | err = DiffBlobs(blob1, "hi", blob2, "hi", nil, |
| 217 | func(delta DiffDelta, progress float64) (DiffForEachHunkCallback, error) { |
| 218 | files++ |
| 219 | return func(hunk DiffHunk) (DiffForEachLineCallback, error) { |
| 220 | hunks++ |
| 221 | return func(line DiffLine) error { |
| 222 | lines++ |
| 223 | return nil |
| 224 | }, nil |
| 225 | }, nil |
| 226 | }, |
| 227 | DiffDetailLines) |
| 228 | |
| 229 | if files != 1 { |
| 230 | t.Fatal("Bad number of files iterated") |
| 231 | } |
| 232 | |
| 233 | if hunks != 1 { |
| 234 | t.Fatal("Bad number of hunks iterated") |
| 235 | } |
| 236 | |
| 237 | // two removals, two additions |
| 238 | if lines != 4 { |
| 239 | t.Fatalf("Bad number of lines iterated") |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | func TestApplyDiffAddfile(t *testing.T) { |
| 244 | repo := createTestRepo(t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…