feat(metadata): SQLite backend, storage reconciliation and local defaults
- pluggable per-domain Repository interfaces; PostgreSQL and SQLite impls - SQLite on modernc.org/sqlite (WAL, busy_timeout, foreign_keys, immediate tx) - separate migrations/sqlite and db.MigrateSQLite; store.NewPostgres/NewSQLite - cmd/reconcile compares object storage with the journal (report, then --delete) - storage.Backend.List and photos.Repository.AllStorageKeys - DB_BACKEND/SQLITE_PATH and STORAGE_BACKEND/FS_ROOT selectable; local defaults (sqlite ./galo.db, fs ./data) - Makefile reconcile/reconcile-delete; docs and .env.example updated
This commit is contained in:
@@ -172,3 +172,33 @@ func TestContentTypeForKey(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFSList(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
fs := newTestFS(t)
|
||||
for _, key := range []string{"objects/a/original.jpg", "objects/b/original.jpg", "misc/readme.txt"} {
|
||||
if err := fs.Put(ctx, key, strings.NewReader("x"), 1, "text/plain"); err != nil {
|
||||
t.Fatalf("put %s: %v", key, err)
|
||||
}
|
||||
}
|
||||
|
||||
all, err := fs.List(ctx, "")
|
||||
if err != nil || len(all) != 3 {
|
||||
t.Fatalf("list all: %v len=%d", err, len(all))
|
||||
}
|
||||
objs, err := fs.List(ctx, "objects/")
|
||||
if err != nil {
|
||||
t.Fatalf("list objects: %v", err)
|
||||
}
|
||||
if len(objs) != 2 {
|
||||
t.Fatalf("list objects len=%d, want 2", len(objs))
|
||||
}
|
||||
for _, o := range objs {
|
||||
if !strings.HasPrefix(o.Key, "objects/") {
|
||||
t.Fatalf("unexpected key %q", o.Key)
|
||||
}
|
||||
if o.Size != 1 || o.ModTime.IsZero() {
|
||||
t.Fatalf("unexpected info %+v", o)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user