All checks were successful
ci/woodpecker/tag/release Pipeline was successful
127 lines
4.1 KiB
Go
127 lines
4.1 KiB
Go
package artifact
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"gitea.maximumdirect.net/eric/seriatim/internal/buildinfo"
|
|
"gitea.maximumdirect.net/eric/seriatim/internal/config"
|
|
"gitea.maximumdirect.net/eric/seriatim/internal/model"
|
|
"gitea.maximumdirect.net/eric/seriatim/schema"
|
|
)
|
|
|
|
func TestFromMergedUsesBuildVersion(t *testing.T) {
|
|
original := buildinfo.Version
|
|
t.Cleanup(func() {
|
|
buildinfo.Version = original
|
|
})
|
|
buildinfo.Version = "v1.0.0-test"
|
|
|
|
transcript := FromMerged(config.Config{}, model.MergedTranscript{})
|
|
if transcript.Metadata.Version != "v1.0.0-test" {
|
|
t.Fatalf("version = %q, want v1.0.0-test", transcript.Metadata.Version)
|
|
}
|
|
}
|
|
|
|
func TestSelectedFromMergedDefaultsToIntermediateTranscript(t *testing.T) {
|
|
got := SelectedFromMerged(config.Config{}, model.MergedTranscript{})
|
|
if _, ok := got.(schema.IntermediateTranscript); !ok {
|
|
t.Fatalf("selected artifact type = %T, want schema.IntermediateTranscript", got)
|
|
}
|
|
}
|
|
|
|
func TestSelectedFromMergedUsesIntermediateWhenConfigured(t *testing.T) {
|
|
got := SelectedFromMerged(config.Config{OutputSchema: config.OutputSchemaIntermediate}, model.MergedTranscript{})
|
|
if _, ok := got.(schema.IntermediateTranscript); !ok {
|
|
t.Fatalf("selected artifact type = %T, want schema.IntermediateTranscript", got)
|
|
}
|
|
}
|
|
|
|
func TestSelectedFromMergedUsesFullWhenConfigured(t *testing.T) {
|
|
got := SelectedFromMerged(config.Config{OutputSchema: config.OutputSchemaFull}, model.MergedTranscript{})
|
|
if _, ok := got.(schema.Transcript); !ok {
|
|
t.Fatalf("selected artifact type = %T, want schema.Transcript", got)
|
|
}
|
|
}
|
|
|
|
func TestIntermediateFromMergedEmitsOnlyIntermediateShape(t *testing.T) {
|
|
merged := model.MergedTranscript{
|
|
Segments: []model.Segment{
|
|
{
|
|
ID: 1,
|
|
Source: "input.json",
|
|
SourceRef: "word-run:1:1:1",
|
|
DerivedFrom: []string{"input.json#0"},
|
|
Speaker: "Alice",
|
|
Start: 1,
|
|
End: 2,
|
|
Text: "hello",
|
|
Categories: []string{"backchannel"},
|
|
OverlapGroupID: 1,
|
|
},
|
|
},
|
|
OverlapGroups: []model.OverlapGroup{
|
|
{ID: 1, Start: 1, End: 2, Segments: []string{"input.json#0"}, Speakers: []string{"Alice"}, Class: "unknown", Resolution: "unresolved"},
|
|
},
|
|
}
|
|
|
|
got := IntermediateFromMerged(config.Config{OutputSchema: config.OutputSchemaIntermediate}, merged)
|
|
want := schema.IntermediateTranscript{
|
|
Metadata: schema.IntermediateMetadata{
|
|
Application: ApplicationName,
|
|
Version: buildinfo.Version,
|
|
OutputSchema: config.OutputSchemaIntermediate,
|
|
},
|
|
Segments: []schema.IntermediateSegment{
|
|
{ID: 1, Start: 1, End: 2, Speaker: "Alice", Text: "hello", Categories: []string{"backchannel"}},
|
|
},
|
|
}
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Fatalf("intermediate transcript = %#v, want %#v", got, want)
|
|
}
|
|
}
|
|
|
|
func TestMinimalFromMergedEmitsOnlyMinimalShape(t *testing.T) {
|
|
merged := model.MergedTranscript{
|
|
Segments: []model.Segment{
|
|
{
|
|
ID: 1,
|
|
Source: "input.json",
|
|
SourceRef: "word-run:1:1:1",
|
|
DerivedFrom: []string{"input.json#0"},
|
|
Speaker: "Alice",
|
|
Start: 1,
|
|
End: 2,
|
|
Text: "hello",
|
|
Categories: []string{"backchannel"},
|
|
OverlapGroupID: 1,
|
|
},
|
|
},
|
|
OverlapGroups: []model.OverlapGroup{
|
|
{ID: 1, Start: 1, End: 2, Segments: []string{"input.json#0"}, Speakers: []string{"Alice"}, Class: "unknown", Resolution: "unresolved"},
|
|
},
|
|
}
|
|
|
|
got := MinimalFromMerged(config.Config{OutputSchema: config.OutputSchemaMinimal}, merged)
|
|
want := schema.MinimalTranscript{
|
|
Metadata: schema.MinimalMetadata{
|
|
Application: ApplicationName,
|
|
Version: buildinfo.Version,
|
|
OutputSchema: config.OutputSchemaMinimal,
|
|
},
|
|
Segments: []schema.MinimalSegment{
|
|
{ID: 1, Start: 1, End: 2, Speaker: "Alice", Text: "hello"},
|
|
},
|
|
}
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Fatalf("minimal transcript = %#v, want %#v", got, want)
|
|
}
|
|
}
|
|
|
|
func TestSelectedFromMergedUsesMinimalWhenConfigured(t *testing.T) {
|
|
got := SelectedFromMerged(config.Config{OutputSchema: config.OutputSchemaMinimal}, model.MergedTranscript{})
|
|
if _, ok := got.(schema.MinimalTranscript); !ok {
|
|
t.Fatalf("selected artifact type = %T, want schema.MinimalTranscript", got)
|
|
}
|
|
}
|