1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-11-27 00:20:27 +02:00

merge v0.23.0-rc changes

This commit is contained in:
Gani Georgiev
2024-09-29 19:23:19 +03:00
parent ad92992324
commit 844f18cac3
753 changed files with 85141 additions and 63396 deletions

View File

@@ -0,0 +1,32 @@
package tests
import (
"errors"
"testing"
validation "github.com/go-ozzo/ozzo-validation/v4"
)
// TestValidationErrors checks whether the provided rawErrors are
// instance of [validation.Errors] and contains the expectedErrors keys.
func TestValidationErrors(t *testing.T, rawErrors error, expectedErrors []string) {
var errs validation.Errors
if rawErrors != nil && !errors.As(rawErrors, &errs) {
t.Fatalf("Failed to parse errors, expected to find validation.Errors, got %T\n%v", rawErrors, rawErrors)
}
if len(errs) != len(expectedErrors) {
keys := make([]string, 0, len(errs))
for k := range errs {
keys = append(keys, k)
}
t.Fatalf("Expected error keys \n%v\ngot\n%v\n%v", expectedErrors, keys, errs)
}
for _, k := range expectedErrors {
if _, ok := errs[k]; !ok {
t.Fatalf("Missing expected error key %q in %v", k, errs)
}
}
}