feat(accounts): add admin accounts and user preferences
Remove public registration, support administrator-managed accounts, and persist personal preferences. Refs #2 #5 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -0,0 +1,34 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestUserPreferencesMigrationDefinesExistingAccountDefaults(t *testing.T) {
|
||||
up, err := os.ReadFile("000011_user_preferences.up.sql")
|
||||
if err != nil {
|
||||
t.Fatalf("read preferences migration: %v", err)
|
||||
}
|
||||
down, err := os.ReadFile("000011_user_preferences.down.sql")
|
||||
if err != nil {
|
||||
t.Fatalf("read preferences rollback: %v", err)
|
||||
}
|
||||
upSQL := strings.ToLower(string(up))
|
||||
for _, fragment := range []string{
|
||||
"alter table users",
|
||||
"default 'fr'",
|
||||
"default 'title'",
|
||||
"'en'",
|
||||
"'title_content'",
|
||||
} {
|
||||
if !strings.Contains(upSQL, fragment) {
|
||||
t.Errorf("preferences migration missing %q", fragment)
|
||||
}
|
||||
}
|
||||
downSQL := strings.ToLower(string(down))
|
||||
if !strings.Contains(downSQL, "alter table users") || !strings.Contains(downSQL, "drop column") {
|
||||
t.Errorf("preferences rollback must remove the added user preference columns; got %s", downSQL)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user