Skip to content

Commit 8f18ec6

Browse files
authored
[chore] [receiver/github] fix flaky test (#37698)
#### Description Fixes a flaky test where when with contracted resources, there was be a one ms delay in calculation of age causing a non-equal comparison. #### Link to tracking issue Fixes #34983 #### Testing Replicated tests locally. Ran 100 tests to replicate failure (2% failure rate) and then repeated after fix (0 failures).
1 parent 19409dd commit 8f18ec6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

receiver/githubreceiver/internal/scraper/githubscraper/helpers_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,12 @@ func TestEvalCommits(t *testing.T) {
899899
assert.Equal(t, tc.expectedAge, age)
900900
assert.Equal(t, tc.expectedDeletions, dels)
901901
assert.Equal(t, tc.expectedAdditions, adds)
902+
// assert.WithinRange(t, age, time.tc.expectedAge, time.Now())
903+
if tc.expectedAge != 0 {
904+
assert.WithinDuration(t, time.UnixMilli(tc.expectedAge), time.UnixMilli(age), 10*time.Second)
905+
} else {
906+
assert.Equal(t, tc.expectedAge, age)
907+
}
902908

903909
if tc.expectedErr == nil {
904910
assert.NoError(t, err)

0 commit comments

Comments
 (0)