feat(notification): add Resend quota gate and waiting-for-reset state
This commit is contained in:
1 parent
3b917befa9
commit
b856d4ff54
40 files changed
+4116
-48
No files matched your search
@@ -29,15 +29,18 @@ const (
|
||||
// deliveryMigrationVersion creates deliveryTableNames (mail requests,
|
||||
// deliveries, and their attempts) and deliveryFunctionNames.
|
||||
deliveryMigrationVersion = 6
|
||||
// mailQuotaMigrationVersion creates mailQuotaTableNames.
|
||||
mailQuotaMigrationVersion = 7
|
||||
)
|
||||
|
||||
var (
|
||||
// Tables created by 00001, 00002, 00003, 00005, and 00006.
|
||||
outboxTables = []string{"outbox_events"}
|
||||
identityTableNames = []string{"users", "email_tokens", "sessions"}
|
||||
policyTableNames = []string{"policy_versions"}
|
||||
consumerTableNames = []string{"consumer_processed_events", "consumer_dead_letters"}
|
||||
deliveryTableNames = []string{"mail_requests", "deliveries", "delivery_attempts"}
|
||||
// Tables created by 00001, 00002, 00003, 00005, 00006, and 00007.
|
||||
outboxTables = []string{"outbox_events"}
|
||||
identityTableNames = []string{"users", "email_tokens", "sessions"}
|
||||
policyTableNames = []string{"policy_versions"}
|
||||
consumerTableNames = []string{"consumer_processed_events", "consumer_dead_letters"}
|
||||
deliveryTableNames = []string{"mail_requests", "deliveries", "delivery_attempts"}
|
||||
mailQuotaTableNames = []string{"mail_quota_usage", "mail_quota_reservations"}
|
||||
// Trigger functions created by 00003 and 00006.
|
||||
policyFunctionNames = []string{"policy_versions_refuse_change()", "policy_versions_stamp_creation()"}
|
||||
deliveryFunctionNames = []string{"deliveries_refuse_content_change()", "delivery_attempts_refuse_update()"}
|
||||
@@ -72,8 +75,9 @@ func TestPostgresMigrations(t *testing.T) {
|
||||
assertTablesExist(ctx, t, pool, true, consumerTableNames...)
|
||||
assertTablesExist(ctx, t, pool, true, deliveryTableNames...)
|
||||
assertFunctionsExist(ctx, t, pool, true, deliveryFunctionNames...)
|
||||
assertTablesExist(ctx, t, pool, true, mailQuotaTableNames...)
|
||||
|
||||
identityRolledBack, policyRolledBack, consumerRolledBack, deliveryRolledBack := false, false, false, false
|
||||
identityRolledBack, policyRolledBack, consumerRolledBack, deliveryRolledBack, mailQuotaRolledBack := false, false, false, false, false
|
||||
for rolledBack := 0; ; rolledBack++ {
|
||||
result, err := migrator.DownOne(ctx)
|
||||
if errors.Is(err, postgresadapter.ErrNoMigrationToRollBack) {
|
||||
@@ -85,6 +89,13 @@ func TestPostgresMigrations(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("DownOne() after %d rollbacks error = %v", rolledBack, err)
|
||||
}
|
||||
if result.Version == mailQuotaMigrationVersion {
|
||||
// The quota migration removes only its counter table; the
|
||||
// deliveries it does not reference stay.
|
||||
assertTablesExist(ctx, t, pool, false, mailQuotaTableNames...)
|
||||
assertTablesExist(ctx, t, pool, true, deliveryTableNames...)
|
||||
mailQuotaRolledBack = true
|
||||
}
|
||||
if result.Version == deliveryMigrationVersion {
|
||||
// The delivery migration removes its tables and functions
|
||||
// and leaves the identity tables they referenced.
|
||||
@@ -115,9 +126,9 @@ func TestPostgresMigrations(t *testing.T) {
|
||||
identityRolledBack = true
|
||||
}
|
||||
}
|
||||
if !identityRolledBack || !policyRolledBack || !consumerRolledBack || !deliveryRolledBack {
|
||||
t.Fatalf("migrations %d, %d, %d, and %d were not all rolled back",
|
||||
identityMigrationVersion, policyMigrationVersion, consumerMigrationVersion, deliveryMigrationVersion)
|
||||
if !identityRolledBack || !policyRolledBack || !consumerRolledBack || !deliveryRolledBack || !mailQuotaRolledBack {
|
||||
t.Fatalf("migrations %d, %d, %d, %d, and %d were not all rolled back",
|
||||
identityMigrationVersion, policyMigrationVersion, consumerMigrationVersion, deliveryMigrationVersion, mailQuotaMigrationVersion)
|
||||
}
|
||||
assertTablesExist(ctx, t, pool, false, outboxTables...)
|
||||
assertTablesExist(ctx, t, pool, false, identityTableNames...)
|
||||
|
||||
Reference in new issue
Block a user