feat(api): sync réel — outbox POST /sync/ops idempotente + snapshot GET /sync/permissions (owner V1)
- operations.operation_id/ref_id BIGINT (= id client pending_operations), UNIQUE(device_id, operation_id) idempotente ; migration 000004 corrigée + test
- service/sync.go : ApplyBatch séquentiel (no-op si déjà traitée ; create déjà présent / update/move sur ressource absente / delete absent = no-op) ;
arrêt à la première erreur non-idempotente (NAME_CONFLICT, NOT_FOUND, INVALID_REQUEST) + trace après succès ; ops share/share_link accusées sans état (V1)
- handlers/sync.go : POST /sync/ops → {applied, failed|null} ; GET /sync/permissions?after= → snapshot delta (effectiveAccess owner, cachedAt ms)
- snapshot : repo.ListOwned (delta updated_at en ms, trié) ; index partiel racine (owner_id, name) WHERE parent_id IS NULL
- GET /files sans folderId = racine uniquement (convention useFiles(undefined)) ; tests files_test corrigés (codes d'erreur imbriqués, tailles)
- fix dbtest : ping la connexion maintenance (création de la DB cible possible) — les tests handlers/repo tournent enfin contre PG réel
- tests handlers end-to-end : batch appliqué + retry idempotent, arrêt sur NAME_CONFLICT, delete idempotent, snapshot + delta
This commit is contained in:
@@ -15,8 +15,8 @@ import (
|
||||
|
||||
// OpenTestDatabase ensures the test database exists, resets its schema, runs
|
||||
// all migrations, and returns a live connection (closed via t.Cleanup).
|
||||
// Tests are skipped when Postgres is unreachable. `databaseURL` empty falls
|
||||
// back to TEST_DATABASE_URL, then to the global default.
|
||||
// Tests are skipped only when Postgres itself is unreachable. `databaseURL`
|
||||
// empty falls back to TEST_DATABASE_URL, then to the global default.
|
||||
func OpenTestDatabase(t *testing.T, databaseURL string) *sql.DB {
|
||||
t.Helper()
|
||||
|
||||
@@ -30,7 +30,15 @@ func OpenTestDatabase(t *testing.T, databaseURL string) *sql.DB {
|
||||
databaseURL = "postgres://vaultdrop:vaultdrop@localhost:5432/vaultdrop_test?sslmode=disable"
|
||||
}
|
||||
|
||||
probe, err := sql.Open("postgres", databaseURL)
|
||||
// Postgres joignable ? (sinon on skippe, sans être gênés par l'existence
|
||||
// ou non de la base cible)
|
||||
parsed, err := url.Parse(databaseURL)
|
||||
if err != nil {
|
||||
t.Fatalf("parse url: %v", err)
|
||||
}
|
||||
maintenance := *parsed
|
||||
maintenance.Path = "/postgres"
|
||||
probe, err := sql.Open("postgres", maintenance.String())
|
||||
if err != nil {
|
||||
t.Fatalf("open: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user