mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-01-10 00:43:36 +02:00
31 lines
567 B
Go
31 lines
567 B
Go
|
package validators_test
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/pocketbase/pocketbase/forms/validators"
|
||
|
)
|
||
|
|
||
|
func TestCompare(t *testing.T) {
|
||
|
scenarios := []struct {
|
||
|
valA string
|
||
|
valB string
|
||
|
expectError bool
|
||
|
}{
|
||
|
{"", "", false},
|
||
|
{"", "456", true},
|
||
|
{"123", "", true},
|
||
|
{"123", "456", true},
|
||
|
{"123", "123", false},
|
||
|
}
|
||
|
|
||
|
for i, s := range scenarios {
|
||
|
err := validators.Compare(s.valA)(s.valB)
|
||
|
|
||
|
hasErr := err != nil
|
||
|
if hasErr != s.expectError {
|
||
|
t.Errorf("(%d) Expected hasErr to be %v, got %v (%v)", i, s.expectError, hasErr, err)
|
||
|
}
|
||
|
}
|
||
|
}
|