30 lines
683 B
Go
30 lines
683 B
Go
package postgres
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestOperationalStatusSQLIsTenantScopedAndReadOnly(t *testing.T) {
|
|
upper := strings.ToUpper(operationalStatusSQL)
|
|
for _, want := range []string{
|
|
"QUESTION_TABLE_EXPORTS",
|
|
"SUPPORT_CASES",
|
|
"TENANT_KEY = $1",
|
|
"FAQ_EXPORT_STATUS",
|
|
"NOTIFICATION_FAILED",
|
|
"MAX(EXPORTED_AT)",
|
|
"MAX(FAQ_EXPORTED_AT)",
|
|
"MAX(NOTIFIED_AT)",
|
|
} {
|
|
if !strings.Contains(upper, want) {
|
|
t.Errorf("status SQL missing %q", want)
|
|
}
|
|
}
|
|
for _, forbidden := range []string{"INSERT ", "UPDATE ", "DELETE ", "FOR UPDATE"} {
|
|
if strings.Contains(upper, forbidden) {
|
|
t.Errorf("status SQL must be read-only; found %q", forbidden)
|
|
}
|
|
}
|
|
}
|