Updated transcript artifact names and canonical paths to use a consistent, role-based nomenclature
This commit is contained in:
123
internal/artifacts/transcripts_test.go
Normal file
123
internal/artifacts/transcripts_test.go
Normal file
@@ -0,0 +1,123 @@
|
||||
package artifacts
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRuntimeTranscriptArtifacts(t *testing.T) {
|
||||
want := []TranscriptArtifactSpec{
|
||||
{
|
||||
SourceID: ArtifactTranscriptBase,
|
||||
CanonicalRelPath: TranscriptPathBase,
|
||||
ProducerStage: "merge",
|
||||
OutputKind: TranscriptOutputKindBase,
|
||||
},
|
||||
{
|
||||
SourceID: ArtifactTranscriptPolished,
|
||||
CanonicalRelPath: TranscriptPathPolished,
|
||||
ProducerStage: "polish",
|
||||
OutputKind: TranscriptOutputKindPolished,
|
||||
},
|
||||
{
|
||||
SourceID: ArtifactTranscriptFinal,
|
||||
CanonicalRelPath: TranscriptPathFinal,
|
||||
ProducerStage: "normalize",
|
||||
OutputKind: TranscriptOutputKindFinal,
|
||||
},
|
||||
{
|
||||
SourceID: ArtifactTranscriptFinalTrimmed,
|
||||
CanonicalRelPath: TranscriptPathFinalTrimmed,
|
||||
ProducerStage: "trim",
|
||||
OutputKind: TranscriptOutputKindFinalTrimmed,
|
||||
},
|
||||
}
|
||||
|
||||
got := RuntimeTranscriptArtifacts()
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("RuntimeTranscriptArtifacts() = %#v, want %#v", got, want)
|
||||
}
|
||||
|
||||
for _, spec := range want {
|
||||
gotSpec, ok := LookupRuntimeTranscriptArtifact(spec.SourceID)
|
||||
if !ok {
|
||||
t.Fatalf("LookupRuntimeTranscriptArtifact(%q) ok = false, want true", spec.SourceID)
|
||||
}
|
||||
if gotSpec != spec {
|
||||
t.Fatalf("LookupRuntimeTranscriptArtifact(%q) = %#v, want %#v", spec.SourceID, gotSpec, spec)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPlannedTranscriptArtifacts(t *testing.T) {
|
||||
want := []TranscriptArtifactSpec{
|
||||
{
|
||||
SourceID: ArtifactTranscriptBase,
|
||||
CanonicalRelPath: TranscriptPathBase,
|
||||
ProducerStage: "merge",
|
||||
OutputKind: TranscriptOutputKindBase,
|
||||
},
|
||||
{
|
||||
SourceID: ArtifactTranscriptPolished,
|
||||
CanonicalRelPath: TranscriptPathPolished,
|
||||
ProducerStage: "polish",
|
||||
OutputKind: TranscriptOutputKindPolished,
|
||||
},
|
||||
{
|
||||
SourceID: ArtifactTranscriptFinal,
|
||||
CanonicalRelPath: TranscriptPathFinal,
|
||||
ProducerStage: "normalize",
|
||||
OutputKind: TranscriptOutputKindFinal,
|
||||
},
|
||||
{
|
||||
SourceID: ArtifactTranscriptFinalTrimmed,
|
||||
CanonicalRelPath: TranscriptPathFinalTrimmed,
|
||||
ProducerStage: "trim",
|
||||
OutputKind: TranscriptOutputKindFinalTrimmed,
|
||||
},
|
||||
}
|
||||
|
||||
got := PlannedTranscriptArtifacts()
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("PlannedTranscriptArtifacts() = %#v, want %#v", got, want)
|
||||
}
|
||||
|
||||
for _, spec := range want {
|
||||
gotSpec, ok := LookupPlannedTranscriptArtifact(spec.SourceID)
|
||||
if !ok {
|
||||
t.Fatalf("LookupPlannedTranscriptArtifact(%q) ok = false, want true", spec.SourceID)
|
||||
}
|
||||
if gotSpec != spec {
|
||||
t.Fatalf("LookupPlannedTranscriptArtifact(%q) = %#v, want %#v", spec.SourceID, gotSpec, spec)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestTranscriptArtifactSlicesAreCopies(t *testing.T) {
|
||||
runtime := RuntimeTranscriptArtifacts()
|
||||
runtime[0].SourceID = "changed"
|
||||
if got := RuntimeTranscriptArtifacts()[0].SourceID; got != ArtifactTranscriptBase {
|
||||
t.Fatalf("RuntimeTranscriptArtifacts()[0].SourceID = %q, want %q", got, ArtifactTranscriptBase)
|
||||
}
|
||||
|
||||
planned := PlannedTranscriptArtifacts()
|
||||
planned[0].SourceID = "changed"
|
||||
if got := PlannedTranscriptArtifacts()[0].SourceID; got != ArtifactTranscriptBase {
|
||||
t.Fatalf("PlannedTranscriptArtifacts()[0].SourceID = %q, want %q", got, ArtifactTranscriptBase)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRuntimeArtifactRegistryUsesTranscriptSpecs(t *testing.T) {
|
||||
for _, transcript := range RuntimeTranscriptArtifacts() {
|
||||
spec, ok := artifactRegistry[transcript.SourceID]
|
||||
if !ok {
|
||||
t.Fatalf("artifactRegistry missing %q", transcript.SourceID)
|
||||
}
|
||||
if spec.CanonicalRelPath != transcript.CanonicalRelPath ||
|
||||
spec.ProducerStage != transcript.ProducerStage ||
|
||||
spec.OutputKind != transcript.OutputKind ||
|
||||
spec.ContentKind != contentTranscriptJSON {
|
||||
t.Fatalf("artifactRegistry[%q] = %#v, want transcript spec %#v", transcript.SourceID, spec, transcript)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user