Skip to content

Commit

Permalink
build: Replace clock library
Browse files Browse the repository at this point in the history
  • Loading branch information
jachym-tousek-keboola committed Jan 6, 2025
1 parent e38c6b6 commit 95084a5
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,11 @@ func TestMetadataCleanup(t *testing.T) {
// -----------------------------------------------------------------------------------------------------------------
var doCleanup func()
{
startTime := clk.Now()
cleanupAttempt := 0
doCleanup = func() {
cleanupAttempt++
clk.Advance(cleanupInterval)
clk.Advance(startTime.Add(time.Duration(cleanupAttempt) * cleanupInterval).Sub(clk.Now()))
assert.EventuallyWithT(t, func(c *assert.CollectT) {
logger.AssertJSONMessages(c, `{"level":"info","message":"deleted \"%d\" files"}`)
}, 2*time.Second, 100*time.Millisecond)
Expand Down Expand Up @@ -234,9 +235,12 @@ func TestMetadataCleanup(t *testing.T) {
}

// Delete success job as it has finished
jobCleanupAttempt := 0
{
logger.Truncate()
clk.Advance(cleanupInterval)
startTime := clk.Now()
jobCleanupAttempt++
clk.Advance(startTime.Add(time.Duration(jobCleanupAttempt) * cleanupInterval).Sub(clk.Now()))
assert.EventuallyWithT(t, func(c *assert.CollectT) {
logger.AssertJSONMessages(c, `{"level":"info","message":"deleted \"%d\" jobs"}`)
}, 2*time.Second, 100*time.Millisecond)
Expand Down Expand Up @@ -325,9 +329,12 @@ func TestMetadataProcessingJobCleanup(t *testing.T) {
}

// Delete processing job as it has finished
jobCleanupAttempt := 0
{
logger.Truncate()
clk.Advance(cleanupInterval)
startTime := clk.Now()
jobCleanupAttempt++
clk.Advance(startTime.Add(time.Duration(jobCleanupAttempt) * cleanupInterval).Sub(clk.Now()))
assert.EventuallyWithT(t, func(c *assert.CollectT) {
logger.AssertJSONMessages(c, `{"level":"info","message":"deleted \"%d\" jobs"}`)
}, 2*time.Second, 100*time.Millisecond)
Expand Down

0 comments on commit 95084a5

Please sign in to comment.