Skip to content

Commit

Permalink
test: Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jachym-tousek-keboola committed Jan 6, 2025
1 parent e2d85f9 commit c453fd4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func TestOpenVolume_WaitForVolumeIDFile_Timeout(t *testing.T) {
defer close(done)
_, err := tc.OpenVolume()
if assert.Error(t, err) {
wildcards.Assert(t, "cannot open volume ID file \"%s\":\n- context deadline exceeded", err.Error())
wildcards.Assert(t, "cannot open volume ID file \"%s\":\n- %s", err.Error(), clockwork.ErrFakeClockDeadlineExceeded)
}
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@ func TestCounterWithBackup_SyncBackupPeriodically(t *testing.T) {

// Sync backup by clock
clk.Advance(backupInterval)
content, err := os.ReadFile(backupPath)
require.NoError(t, err)
assert.Equal(t, "5,2001-01-01T00:00:00.000Z,2002-01-01T00:00:00.000Z", string(content))
assert.EventuallyWithT(t, func(collect *assert.CollectT) {
content, err := os.ReadFile(backupPath)
require.NoError(t, err)
assert.Equal(t, "5,2001-01-01T00:00:00.000Z,2002-01-01T00:00:00.000Z", string(content))
}, 5*time.Second, 10*time.Millisecond)

// Add 4
c.Add(utctime.MustParse("2003-01-01T00:00:00.000Z").Time(), 4)
Expand All @@ -165,7 +167,7 @@ func TestCounterWithBackup_SyncBackupPeriodically(t *testing.T) {
// Close (sync backup)
clk.Advance(backupInterval)
require.NoError(t, c.Close())
content, err = os.ReadFile(backupPath)
content, err := os.ReadFile(backupPath)
require.NoError(t, err)
assert.Equal(t, "9,2001-01-01T00:00:00.000Z,2003-01-01T00:00:00.000Z", string(content))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,11 @@ func TestMeterWithBackup_SyncBackupPeriodically(t *testing.T) {

// Sync backup by clock
clk.Advance(backupInterval)
content, err := os.ReadFile(backupPath)
require.NoError(t, err)
assert.Equal(t, "6", string(content))
assert.EventuallyWithT(t, func(collect *assert.CollectT) {
content, err := os.ReadFile(backupPath)
require.NoError(t, err)
assert.Equal(t, "6", string(content))
}, 5*time.Second, 10*time.Millisecond)

// Data
out.writeError = nil
Expand All @@ -199,7 +201,7 @@ func TestMeterWithBackup_SyncBackupPeriodically(t *testing.T) {
// Close (flush backup)
clk.Advance(backupInterval)
require.NoError(t, m.Close())
content, err = os.ReadFile(backupPath)
content, err := os.ReadFile(backupPath)
require.NoError(t, err)
assert.Equal(t, "9", string(content))

Expand Down

0 comments on commit c453fd4

Please sign in to comment.