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.
This commit is contained in:
2026-10-23 21:45:47 +02:00
parent 98924041c9
commit 0428093d33

View File

@@ -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()