53 lines
1.5 KiB
Go
53 lines
1.5 KiB
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func TestListInboxNodesReturnsOnlyCapturedArtifacts(t *testing.T) {
|
|
app, _ := setupTestApp(t)
|
|
|
|
manual, err := app.CreateNodeFromTemplate("", "Manual Root", "folder.default")
|
|
if err != nil {
|
|
t.Fatalf("create manual root: %v", err)
|
|
}
|
|
legacyInbox, err := app.CreateNodeFromTemplate("", "Legacy Inbox Root", "folder.default")
|
|
if err != nil {
|
|
t.Fatalf("create legacy inbox root: %v", err)
|
|
}
|
|
captured, err := app.CreateNodeFromTemplate("", "Captured Artifact", "folder.default")
|
|
if err != nil {
|
|
t.Fatalf("create captured artifact: %v", err)
|
|
}
|
|
child, err := app.CreateNodeFromTemplate(captured.ID, "Nested Child", "folder.default")
|
|
if err != nil {
|
|
t.Fatalf("create child: %v", err)
|
|
}
|
|
if _, err := app.db.Exec(`UPDATE nodes SET section = 'inbox' WHERE id = ?`, legacyInbox.ID); err != nil {
|
|
t.Fatalf("mark legacy inbox: %v", err)
|
|
}
|
|
if err := app.nodes.MetaSet(captured.ID, "capture.inbox", "true"); err != nil {
|
|
t.Fatalf("mark captured: %v", err)
|
|
}
|
|
|
|
list, err := app.ListInboxNodes()
|
|
if err != nil {
|
|
t.Fatalf("ListInboxNodes: %v", err)
|
|
}
|
|
|
|
got := map[string]bool{}
|
|
for _, item := range list {
|
|
got[item.ID] = true
|
|
}
|
|
if !got[captured.ID] {
|
|
t.Fatal("captured artifact missing from inbox")
|
|
}
|
|
if got[manual.ID] {
|
|
t.Fatal("manual root should not be in inbox")
|
|
}
|
|
if got[legacyInbox.ID] {
|
|
t.Fatal("section=inbox root without capture metadata should not be in inbox")
|
|
}
|
|
if got[child.ID] {
|
|
t.Fatal("nested child should not be in inbox")
|
|
}
|
|
}
|