A report the store cannot take yet is handed back to the broker, not acknowledged and lost (novox/hq issue 082)

This commit is contained in:
2026-09-22 13:25:13 +02:00
parent ff26ea959d
commit 047830a6b5
5 changed files with 157 additions and 1 deletions
+28
View File
@@ -0,0 +1,28 @@
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)
}
}
}