Skip to content

Commit e6940c6

Browse files
committed
refactor: determine if we need updating based on the number of obsolete tests
1 parent 9137b42 commit e6940c6

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

snaps/clean.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,6 @@ func examineSnaps(
251251
return nil, isDirty, err
252252
}
253253

254-
var needsUpdating bool
255-
256254
registeredTests := occurrences(registry[snapPath], count, snapshotOccurrenceFMT)
257255
s := snapshotScanner(f)
258256

@@ -267,7 +265,6 @@ func examineSnaps(
267265

268266
if !registeredTests.Has(testID) && !testSkipped(testID, runOnly) {
269267
obsoleteTests = append(obsoleteTests, testID)
270-
needsUpdating = true
271268

272269
removeSnapshot(s)
273270
continue
@@ -297,7 +294,7 @@ func examineSnaps(
297294
// if we're not allowed to update anything, just capture if the snapshot
298295
// needs cleaning, and then continue to the next snapshot
299296
if !shouldUpdate {
300-
if needsUpdating || needsSorting {
297+
if len(obsoleteTests) > 0 || needsSorting {
301298
isDirty = true
302299
}
303300

0 commit comments

Comments
 (0)