29 lines
805 B
Go
29 lines
805 B
Go
package inventory
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/jackc/pgx/v5/pgconn"
|
|
)
|
|
|
|
// The store restarting is "not now"; a constraint the store enforced is an answer (issue 082).
|
|
func TestAStoreThatIsStartingIsUnreachableAndARefusalIsNot(t *testing.T) {
|
|
for _, c := range []struct {
|
|
err error
|
|
want bool
|
|
}{
|
|
{&pgconn.PgError{Code: "57P03", Message: "the database system is starting up"}, true},
|
|
{fmt.Errorf("recording: %w", &pgconn.PgError{Code: "57P01"}), true},
|
|
{&pgconn.PgError{Code: "08006"}, true},
|
|
{&pgconn.PgError{Code: "23503", Message: "violates foreign key constraint"}, false},
|
|
{errors.New("a report named no node"), false},
|
|
{nil, false},
|
|
} {
|
|
if got := Unreachable(c.err); got != c.want {
|
|
t.Errorf("Unreachable(%v) = %v, want %v", c.err, got, c.want)
|
|
}
|
|
}
|
|
}
|