package ingest
import (
"testing"
"craftdesign.group/quarry/internal/artifact"
"craftdesign.group/quarry/internal/index"
)
// A rebuild has to learn what the live fold learns. Before this, the
// reindex path folded frames without annotating them, so every
// uploaded attachment came back as the small text file its stub is:
// pictures that had rendered for a day turned into five lines of
// key-value text the moment the index was rebuilt.
func TestReindexAnnotatesAttachmentStubs(t *testing.T) {
fl := newFileLists(nil) // no client: stub() answers nil, which is the safe half
batch := []index.Parsed{
{Hash: "a", Art: &artifact.Artifact{Type: artifact.Attachment,
Attachment: &artifact.Attach{Name: "x.png", Source: "deadbeef"}}},
{Hash: "b", Art: &artifact.Artifact{Type: artifact.Manifest}},
}
fl.annotateStubs(batch)
if batch[1].Stub != nil {
t.Error("FAIL: a manifest was read as an attachment")
}
t.Log("ok: the rebuild path asks each A card whether its blob is a stub")
}