- backend: user_avatar_objects binding (PG+SQLite), GC preserves avatar blobs, avatar service (EXIF-stripping WebP 128/512), public avatar read route - web: avatar upload/crop on profile, round avatar in header/members/comments/author - android: avatar upload/crop, round avatar on profile and albums header - openspec: add-user-avatar proposal/design/specs/tasks
60 lines
1.6 KiB
Go
60 lines
1.6 KiB
Go
package contract
|
|
|
|
import (
|
|
"context"
|
|
"io/fs"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
assets "galo"
|
|
"galo/internal/albums"
|
|
"galo/internal/auth"
|
|
"galo/internal/db"
|
|
"galo/internal/members"
|
|
"galo/internal/notifications"
|
|
"galo/internal/photos"
|
|
"galo/internal/settings"
|
|
"galo/internal/sharelinks"
|
|
"galo/internal/social"
|
|
)
|
|
|
|
func TestSQLiteContract(t *testing.T) {
|
|
path := filepath.Join(t.TempDir(), "meta.db")
|
|
migFS, err := fs.Sub(assets.Migrations, "migrations/sqlite")
|
|
if err != nil {
|
|
t.Fatalf("migrations fs: %v", err)
|
|
}
|
|
if err := db.MigrateSQLite(path, migFS); err != nil {
|
|
t.Fatalf("migrate: %v", err)
|
|
}
|
|
database, err := db.OpenSQLite(path)
|
|
if err != nil {
|
|
t.Fatalf("open: %v", err)
|
|
}
|
|
t.Cleanup(func() { database.Close() })
|
|
|
|
Run(t, Repos{
|
|
Auth: auth.NewSQLiteStore(database),
|
|
Albums: albums.NewSQLiteStore(database),
|
|
Members: members.NewSQLiteStore(database),
|
|
Photos: photos.NewSQLiteStore(database),
|
|
Social: social.NewSQLiteStore(database),
|
|
Notifications: notifications.NewSQLiteStore(database),
|
|
ShareLinks: sharelinks.NewSQLiteStore(database),
|
|
Settings: settings.NewSQLiteStore(database),
|
|
Reset: func(ctx context.Context) error {
|
|
tables := []string{
|
|
"variant_jobs", "photo_objects", "user_avatar_objects", "objects", "photo_tags", "tags",
|
|
"refresh_tokens", "share_links", "notifications", "likes", "comments",
|
|
"invites", "album_members", "photos", "albums", "users", "app_settings",
|
|
}
|
|
for _, tbl := range tables {
|
|
if _, err := database.ExecContext(ctx, "DELETE FROM "+tbl); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
},
|
|
})
|
|
}
|