test: wait for time.Now to change before updating stack in pkger test (#22735)

Do this so comparisons between creation time and update time are realistic.
pull/22738/head
Daniel Moran 2021-10-22 16:20:17 -04:00 committed by GitHub
parent 5e6b0d539b
commit 7171e0752a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -549,6 +549,13 @@ func TestLauncher_Pkger(t *testing.T) {
})
defer cleanup()
// Wait for time.Now() to move ahead of the stack's latest update time.
// We do this so that on Windows (where time.Now() is updated relatively slowly)
// it doesn't appear that the stack was updated at the same time it was created.
for now := time.Now(); now.Equal(stack.LatestEvent().UpdatedAt); now = time.Now() {
time.Sleep(time.Millisecond)
}
assertStack := func(t *testing.T, st pkger.Stack) {
t.Helper()
assert.Equal(t, stack.ID, st.ID)