1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-01-10 00:43:36 +02:00
pocketbase/forms/realtime_subscribe_test.go
2024-01-03 04:30:20 +02:00

34 lines
583 B
Go

package forms_test
import (
"strings"
"testing"
"github.com/pocketbase/pocketbase/forms"
)
func TestRealtimeSubscribeValidate(t *testing.T) {
t.Parallel()
scenarios := []struct {
clientId string
expectError bool
}{
{"", true},
{strings.Repeat("a", 256), true},
{"test", false},
}
for i, s := range scenarios {
form := forms.NewRealtimeSubscribe()
form.ClientId = s.clientId
err := form.Validate()
hasErr := err != nil
if hasErr != s.expectError {
t.Errorf("(%d) Expected hasErr to be %v, got %v (%v)", i, s.expectError, hasErr, err)
}
}
}