From 2c6dc1556c0869b471eaaff0e7fec022825f51e6 Mon Sep 17 00:00:00 2001 From: Arne Luenser Date: Mon, 23 Dec 2024 10:36:48 +0100 Subject: [PATCH] fix: test --- selfservice/strategy/code/test/persistence.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/selfservice/strategy/code/test/persistence.go b/selfservice/strategy/code/test/persistence.go index 85b06e561862..f44d50025b94 100644 --- a/selfservice/strategy/code/test/persistence.go +++ b/selfservice/strategy/code/test/persistence.go @@ -123,8 +123,7 @@ func TestPersister(ctx context.Context, p interface { go func() { defer wg.Done() _, err := p.UseRecoveryCode(ctx, f.ID, "i-do-not-exist") - if err == nil { - t.Error("should have rejected incorrect code") + if !assert.Error(t, err) { return } if errors.Is(err, code.ErrCodeSubmittedTooOften) { @@ -135,11 +134,9 @@ func TestPersister(ctx context.Context, p interface { }() } wg.Wait() - require.EqualValues(t, 5, wrongCode, "should reject 5 times with wrong code") - require.EqualValues(t, 45, tooOften, "should reject 45 times with too often") - _, err = p.UseRecoveryCode(ctx, f.ID, "i-do-not-exist") - require.ErrorIs(t, err, code.ErrCodeSubmittedTooOften) + require.EqualValues(t, 50, wrongCode+tooOften, "all 50 attempts made") + require.LessOrEqual(t, wrongCode, 5, "max. 5 attempts have gone past the duplication check") // Submit again, just to be sure _, err = p.UseRecoveryCode(ctx, f.ID, "i-do-not-exist")