57f5219628
Each recorded artifact now carries a server group (deliverable or debug). public/ files are deliverables; input/memory/history/output.md, session exports and private/ scratch are debugging files. The app's Artifacts tab lists deliverables and the Debug toggle reveals a separate Debugging files group (older servers fall back to the filename rule); the TUI lists deliverables first and marks debug rows; artifact search excludes debug files unless include_debug / --debug-files is set.
50 lines
1.8 KiB
Go
50 lines
1.8 KiB
Go
package protocol
|
|
|
|
import "testing"
|
|
|
|
func groupsByName(files []StageArtifact) map[string]string {
|
|
groups := map[string]string{}
|
|
for _, file := range files {
|
|
groups[file.Name] = file.Group
|
|
}
|
|
return groups
|
|
}
|
|
|
|
func TestClassifyArtifactsTurnVisit(t *testing.T) {
|
|
input := []StageArtifact{
|
|
{Name: "input.md"}, {Name: "memory.md"}, {Name: "history.md"}, {Name: "output.md"},
|
|
{Name: "session.html"}, {Name: "session-repair-1.html"}, {Name: "private/shot.png"},
|
|
{Name: "notes.txt"}, {Name: "public/report.html"}, {Name: "public/history.md"},
|
|
}
|
|
got := groupsByName(ClassifyArtifacts(input))
|
|
want := map[string]string{
|
|
"input.md": ArtifactGroupDebug, "memory.md": ArtifactGroupDebug, "history.md": ArtifactGroupDebug,
|
|
"output.md": ArtifactGroupDebug, "session.html": ArtifactGroupDebug, "session-repair-1.html": ArtifactGroupDebug,
|
|
"private/shot.png": ArtifactGroupDebug, "notes.txt": ArtifactGroupDebug,
|
|
"public/report.html": ArtifactGroupDeliverable, "public/history.md": ArtifactGroupDeliverable,
|
|
}
|
|
for name, group := range want {
|
|
if got[name] != group {
|
|
t.Errorf("%s: group %q, want %q", name, got[name], group)
|
|
}
|
|
}
|
|
for _, file := range input {
|
|
if file.Group != "" {
|
|
t.Fatalf("ClassifyArtifacts mutated its input: %+v", file)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestClassifyArtifactsLegacyVisitKeepsFilesAsDeliverables(t *testing.T) {
|
|
got := groupsByName(ClassifyArtifacts([]StageArtifact{{Name: "report.png"}, {Name: "private/scratch.txt"}}))
|
|
if got["report.png"] != ArtifactGroupDeliverable {
|
|
t.Errorf("legacy file group %q, want deliverable", got["report.png"])
|
|
}
|
|
if got["private/scratch.txt"] != ArtifactGroupDebug {
|
|
t.Errorf("private file group %q, want debug", got["private/scratch.txt"])
|
|
}
|
|
if ClassifyArtifacts(nil) != nil {
|
|
t.Error("nil input must stay nil")
|
|
}
|
|
}
|