Poubelle par utilisateur (backend) : dossier virtuel .poubelle, restauration, suppression définitive, purge automatique (trashDays)
This commit is contained in:
1 parent
8c29eb35e7
commit
8a1417055b
9 files changed
+634
-37
No files matched your search
@@ -67,7 +67,7 @@ func TestFavoritesPerUser(t *testing.T) {
|
||||
}
|
||||
var root []storage.Entry
|
||||
call(t, srv, "bob@x.fr", "GET", "/api/list?path=", "", &root)
|
||||
if len(root) != 3 || root[0].Special != "favoris" || root[2].Favorite {
|
||||
if len(root) != 4 || root[0].Special != "favoris" || root[2].Special != "poubelle" || root[3].Favorite {
|
||||
t.Fatalf("racine de bob = %+v", root)
|
||||
}
|
||||
if c := call(t, srv, "bob@x.fr", "GET", "/api/file?path=.perso/mine.excalidraw", "", nil); c != 404 {
|
||||
@@ -87,3 +87,41 @@ func TestFavoritesPerUser(t *testing.T) {
|
||||
t.Fatalf("écriture dans Favoris : %d", c)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTrash(t *testing.T) {
|
||||
srv := newServer(t)
|
||||
call(t, srv, "alice@x.fr", "PUT", "/api/file?path=d/a.excalidraw", doc, nil)
|
||||
if c := call(t, srv, "alice@x.fr", "DELETE", "/api/entry?path=d/a.excalidraw", "", nil); c != 204 {
|
||||
t.Fatalf("suppression : %d", c)
|
||||
}
|
||||
var items []storage.Entry
|
||||
call(t, srv, "bob@x.fr", "GET", "/api/list?path=.poubelle", "", &items)
|
||||
if len(items) != 1 || items[0].Origin != "d/a.excalidraw" || items[0].By != "alice@x.fr" {
|
||||
t.Fatalf("poubelle vue par bob = %+v", items)
|
||||
}
|
||||
var res []storage.MoveResult
|
||||
if c := call(t, srv, "bob@x.fr", "POST", "/api/trash/restore", `{"paths":["`+items[0].Path+`"]}`, &res); c != 200 ||
|
||||
len(res) != 1 || res[0].To != "d/a.excalidraw" {
|
||||
t.Fatalf("restauration : %d %+v", c, res)
|
||||
}
|
||||
if c := call(t, srv, "alice@x.fr", "GET", "/api/file?path=d/a.excalidraw", "", nil); c != 200 {
|
||||
t.Fatalf("lecture après restauration : %d", c)
|
||||
}
|
||||
|
||||
// Réglage de la purge, puis vidage.
|
||||
var st storage.Settings
|
||||
if c := call(t, srv, "alice@x.fr", "PUT", "/api/settings", `{"trashDays":7}`, &st); c != 200 || st.TrashDays != 7 {
|
||||
t.Fatalf("trashDays : %d %+v", c, st)
|
||||
}
|
||||
if c := call(t, srv, "alice@x.fr", "PUT", "/api/settings", `{"trashDays":-3}`, nil); c != 400 {
|
||||
t.Fatalf("trashDays négatif : %d", c)
|
||||
}
|
||||
call(t, srv, "alice@x.fr", "DELETE", "/api/entry?path=d/a.excalidraw", "", nil)
|
||||
if c := call(t, srv, "alice@x.fr", "DELETE", "/api/entry?path=.poubelle", "", nil); c != 204 {
|
||||
t.Fatalf("vidage : %d", c)
|
||||
}
|
||||
call(t, srv, "alice@x.fr", "GET", "/api/list?path=.poubelle", "", &items)
|
||||
if len(items) != 0 {
|
||||
t.Fatalf("poubelle après vidage = %+v", items)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user