storj/satellite/mailservice/simulate/nomail.go

27 lines
538 B
Go
Raw Normal View History

satellite/consoleweb: fix flaky TestAuth tests We had a lot of flaky test failures from TestAuth. The error message (WHICH IS NOT VISIBLE IN JEKNINS, only in tests.json): ``` FAIL: TestAuth_Register_NameSpecialChars/Postgres (1.04s) panic: runtime error: index out of range [0] with length 0 [recovered] panic: runtime error: index out of range [0] with length 0 goroutine 3473 [running]: testing.tRunner.func1.2({0x235fe40, 0xc000fe6a08}) /usr/local/go/src/testing/testing.go:1209 +0x36c testing.tRunner.func1() /usr/local/go/src/testing/testing.go:1212 +0x3b6 panic({0x235fe40, 0xc000fe6a08}) /usr/local/go/src/runtime/panic.go:1047 +0x266 storj.io/storj/satellite/console/consoleweb/consoleapi_test.TestAuth_Register_NameSpecialChars.func1(0xc001a281a0, 0x289d650, 0xc001a30000) /var/lib/jenkins/workspace/storj-gerrit-verify/satellite/console/consoleweb/consoleapi/auth_test.go:773 +0x785 storj.io/storj/private/testplanet.Run.func1.1({0x289c770, 0xc0001b8008}) /var/lib/jenkins/workspace/storj-gerrit-verify/private/testplanet/run.go:67 +0x732 storj.io/storj/private/testmonkit.RunWith({0x289c770, 0xc0001b8008}, {0x28d89b0, 0xc001a281a0}, {0x1, {0x0, 0x0}, {0x0, 0x0, 0x0}}, ...) ``` The root cause: testplanet uses a simulated mail sender which clicks to all the registration links by default (async). These tests creat links and check the unverified users, but without enough luck the mail sender may already clicks to the link which makes the user verified. Change-Id: I17cd6bf4ae3e7adc223ec693976bb609370f0c44
2022-08-04 12:31:47 +01:00
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information
package simulate
import (
"context"
"net/mail"
"storj.io/storj/private/post"
)
// NoMail doesn't send out any mail.
type NoMail struct {
}
// SendEmail implements func from mailservice.Sender.
func (n NoMail) SendEmail(ctx context.Context, msg *post.Message) error {
return nil
}
// FromAddress implements func from mailservice.Sender.
func (n NoMail) FromAddress() post.Address {
addr, _ := mail.ParseAddress("nosuchmail@storj.io")
return *addr
}