- money_field_test.go: compile gates (moved from the smoke file and extended), model column gate, save-time value check, list projection - settings secret projection and put without a database; tabs, settings richeditor sanitize and the danger flag as internal unit tests - Postgres: TestMoneyFieldSave, TestSettingsSecretPostgres and the Phase 18 payload cases of TestPhase10OpenAPIConformance - vitest: money.ts helpers spec, MoneyField blur-only and server-error cases - gate arrays and the cabana README Testing section name every test
46 lines
1.5 KiB
Go
46 lines
1.5 KiB
Go
package cabana
|
|
|
|
import (
|
|
"time"
|
|
|
|
"git.golem15.com/golem15/summercms/modules/pact"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// AdminAPIRoutes exposes the admin API route inventory (method plus
|
|
// prefix-relative path) to the external conformance test.
|
|
func AdminAPIRoutes() []string {
|
|
out := make([]string, 0, len(phase09Routes))
|
|
for _, route := range phase09Routes {
|
|
if !route.spa {
|
|
out = append(out, route.key)
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
// IssueTestAPIToken mints a personal API token for ownerID with the given
|
|
// scopes and optional expiry. Used by external Postgres smoke tests before
|
|
// the HTTP create route exists.
|
|
func IssueTestAPIToken(db *gorm.DB, ownerID uint, scopes []string, expiresAt *time.Time) (plain string, err error) {
|
|
plain, _, err = insertAPIToken(db, ownerID, "test", scopes, expiresAt)
|
|
return plain, err
|
|
}
|
|
|
|
// ValidateMoneyValue exposes the money field's save check (phrase key and
|
|
// placeholders of the first failure, "" when accepted) to the external
|
|
// money field tests.
|
|
func ValidateMoneyValue(value any, scale int, max string) (string, map[string]string) {
|
|
return validateMoneyValue(value, scale, max)
|
|
}
|
|
|
|
// CheckMoneyType exposes the money field's model column gate to the
|
|
// external money field tests.
|
|
func CheckMoneyType(model any, field FormField) error { return checkMoneyType(model, field) }
|
|
|
|
// ProjectRow exposes one list row's projection to the external money
|
|
// column tests.
|
|
func ProjectRow(row any, controller pact.AdminController, cols []ListColumn) map[string]any {
|
|
return projectRow(row, controller, cols)
|
|
}
|