Skip to content

Commit

Permalink
Make test more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
ycombinator committed Oct 12, 2023
1 parent d84ac77 commit a464077
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ func TestDownloadLogProgressWithLength(t *testing.T) {
`^download from ` + expectedURL + `(.sha512)? completed in \d+ \S+ @ \S+$`,
)

// Consider only progress logs
obs = obs.Filter(func(entry observer.LoggedEntry) bool {
return expectedProgressRegexp.MatchString(entry.Message) ||
expectedCompletedRegexp.MatchString(entry.Message)
})

// Two files are downloaded. Each file is being downloaded in 100 chunks with a delay of 10ms between chunks. The
// expected time to download is, therefore, 100 * 10ms = 1000ms. In reality, the actual download time will be a bit
// more than 1000ms because some time is spent downloading the chunk, in between inter-chunk delays.
Expand Down Expand Up @@ -200,6 +206,12 @@ func TestDownloadLogProgressWithoutLength(t *testing.T) {
`^download from ` + expectedURL + `(.sha512)? completed in \d+ \S+ @ \S+$`,
)

// Consider only progress logs
obs = obs.Filter(func(entry observer.LoggedEntry) bool {
return expectedProgressRegexp.MatchString(entry.Message) ||
expectedCompletedRegexp.MatchString(entry.Message)
})

// Two files are downloaded. Each file is being downloaded in 100 chunks with a delay of 10ms between chunks. The
// expected time to download is, therefore, 100 * 10ms = 1000ms. In reality, the actual download time will be a bit
// more than 1000ms because some time is spent downloading the chunk, in between inter-chunk delays.
Expand Down

0 comments on commit a464077

Please sign in to comment.