Fixed potential test failures due to timing.
This commit is contained in:
parent
acebcf0ba0
commit
8fa6ebb8cf
2 changed files with 4 additions and 3 deletions
|
|
@ -16,7 +16,7 @@ func TestIsCanceled(t *testing.T) {
|
||||||
assert.True(t, IsCanceledError(ctx.Err()))
|
assert.True(t, IsCanceledError(ctx.Err()))
|
||||||
|
|
||||||
ctx, cancel = context.WithTimeout(context.Background(), time.Microsecond)
|
ctx, cancel = context.WithTimeout(context.Background(), time.Microsecond)
|
||||||
time.Sleep(time.Microsecond * 2)
|
time.Sleep(time.Microsecond * 5)
|
||||||
cancel()
|
cancel()
|
||||||
assert.False(t, IsCanceledError(ctx.Err()))
|
assert.False(t, IsCanceledError(ctx.Err()))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,12 +70,13 @@ func TestAuthClient_GetValidPasswordToken(t *testing.T) {
|
||||||
assert.Equal(t, pt.ID, pt2.ID)
|
assert.Equal(t, pt.ID, pt2.ID)
|
||||||
|
|
||||||
// Expire the token by pushing the date far enough back
|
// Expire the token by pushing the date far enough back
|
||||||
_, err = c.ORM.PasswordToken.
|
count, err := c.ORM.PasswordToken.
|
||||||
Update().
|
Update().
|
||||||
SetCreatedAt(time.Now().Add(-(c.Config.App.PasswordToken.Expiration + 3600))).
|
SetCreatedAt(time.Now().Add(-(c.Config.App.PasswordToken.Expiration + time.Hour))).
|
||||||
Where(passwordtoken.ID(pt.ID)).
|
Where(passwordtoken.ID(pt.ID)).
|
||||||
Save(context.Background())
|
Save(context.Background())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, 1, count)
|
||||||
|
|
||||||
// Expired tokens should not be valid
|
// Expired tokens should not be valid
|
||||||
_, err = c.Auth.GetValidPasswordToken(ctx, usr.ID, pt.ID, token)
|
_, err = c.Auth.GetValidPasswordToken(ctx, usr.ID, pt.ID, token)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue