Files
warmbly/internal/utils/validate/uuid_test.go
T
Matthew MeszarosandDevin AI dfed1e1593 feat: validate API UUIDs, recover expired Gmail history and guard consumer startup and stale frontend assets
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-07 07:19:15 +00:00

33 lines
795 B
Go

package validate
import (
"reflect"
"strings"
"testing"
"github.com/google/uuid"
)
func TestUuids(t *testing.T) {
id := uuid.NewString()
for _, tc := range []struct {
name string
in, want []string
invalid bool
}{
{"omitted", nil, nil, false},
{"clear", []string{}, []string{}, false},
{"canonical set", []string{id, strings.ToUpper(id), strings.ReplaceAll(id, "-", "")}, []string{id}, false},
{"invalid", []string{"cro-c6"}, nil, true},
{"mixed", []string{id, "cro-c6"}, nil, true},
{"empty id", []string{""}, nil, true},
} {
t.Run(tc.name, func(t *testing.T) {
got, err := Uuids(tc.in)
if (err != nil) != tc.invalid || !reflect.DeepEqual(got, tc.want) {
t.Fatalf("Uuids = %v, %v; want %v, invalid=%t", got, err, tc.want, tc.invalid)
}
})
}
}