Remove public registration, support administrator-managed accounts, and persist personal preferences. Refs #2 #5 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
19 lines
578 B
Go
19 lines
578 B
Go
package models
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin/binding"
|
|
"testing"
|
|
)
|
|
|
|
func TestPreferencesValidation(t *testing.T) {
|
|
for _, language := range []string{"fr", "en", "de", "", "FR"} {
|
|
for _, mode := range []string{"title", "title_content", "unknown", ""} {
|
|
p := UserPreferences{Language: language, RankingMode: mode}
|
|
wantValid := (language == "fr" || language == "en") && (mode == "title" || mode == "title_content")
|
|
if err := binding.Validator.ValidateStruct(p); (err == nil) != wantValid {
|
|
t.Fatalf("%+v: valid=%v error=%v", p, wantValid, err)
|
|
}
|
|
}
|
|
}
|
|
}
|