From 0428093d337af2b2ea51ff5ea07fc71afb5458e4 Mon Sep 17 00:00:00 2001 From: Jakub Zych Date: Fri, 23 Oct 2026 21:45:47 +0200 Subject: [PATCH] test: start the link request before minting the session in TestBackendLink Go evaluates call arguments left to right, so the two subtests minted the frontend session before the administrator created the link request. Across a second boundary (a loaded host) the confirm correctly answered 409 stale_session, because the sign-in predated the request. --- backend_link_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend_link_test.go b/backend_link_test.go index 6ef40ed..019619c 100644 --- a/backend_link_test.go +++ b/backend_link_test.go @@ -174,7 +174,8 @@ func TestBackendLink(t *testing.T) { token := env.admin(t) admin := adminID(t, token) user := env.seedUser(t, "admin-gone", nil) - if status, body := env.confirmLink(t, freshUserToken(t, user), env.startLink(t, token)); status != http.StatusOK { + code := env.startLink(t, token) // the request first: the sign-in must not predate it + if status, body := env.confirmLink(t, freshUserToken(t, user), code); status != http.StatusOK { t.Fatalf("link = %d %s", status, body) } check := func(want bool, why string) { @@ -196,7 +197,8 @@ func TestBackendLink(t *testing.T) { token := env.admin(t) admin := adminID(t, token) user := env.seedUser(t, "deactivated", nil) - if status, body := env.confirmLink(t, freshUserToken(t, user), env.startLink(t, token)); status != http.StatusOK { + code := env.startLink(t, token) // the request first: the sign-in must not predate it + if status, body := env.confirmLink(t, freshUserToken(t, user), code); status != http.StatusOK { t.Fatalf("link = %d %s", status, body) } spy.reset()