Document and verify multi-format audio discovery
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"sort"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -31,7 +33,7 @@ func TestAudioInspectionAgreesWithPreparation(t *testing.T) {
|
||||
cfg := testConfig(t)
|
||||
root := filepath.Dir(cfg.SessionPath)
|
||||
for _, name := range tc.files {
|
||||
mustWriteFile(t, filepath.Join(root, name), "audio")
|
||||
mustWriteFile(t, filepath.Join(root, name), name)
|
||||
}
|
||||
if tc.directory {
|
||||
cfg.Session.Inputs.AudioFiles = nil
|
||||
@@ -59,14 +61,27 @@ func TestAudioInspectionAgreesWithPreparation(t *testing.T) {
|
||||
t.Fatalf("prepare error: %v", err)
|
||||
}
|
||||
if !tc.reject {
|
||||
count := 0
|
||||
var expected, actual []string
|
||||
for _, source := range check.Paths {
|
||||
b, err := os.ReadFile(source)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
expected = append(expected, string(b))
|
||||
}
|
||||
for _, input := range m.Inputs {
|
||||
if input.Kind == "audio" {
|
||||
count++
|
||||
b, err := os.ReadFile(input.Path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
actual = append(actual, string(b))
|
||||
}
|
||||
}
|
||||
if count != len(check.Paths) {
|
||||
t.Fatalf("inspection paths %v, prepared %d", check.Paths, count)
|
||||
sort.Strings(expected)
|
||||
sort.Strings(actual)
|
||||
if !slices.Equal(expected, actual) {
|
||||
t.Fatalf("inspection content %v, prepared %v", expected, actual)
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -91,8 +106,8 @@ func TestRemoteAudioInspectionAgreesWithPreparation(t *testing.T) {
|
||||
if (check.Err != nil) != collision {
|
||||
t.Fatalf("inspection error: %v", check.Err)
|
||||
}
|
||||
if len(fake.Reads) != 0 {
|
||||
t.Fatal("inspection downloaded audio")
|
||||
if len(fake.Reads) != 0 || len(fake.Uploads) != 0 || len(fake.Deletes) != 0 {
|
||||
t.Fatal("inspection performed a remote mutation or download")
|
||||
}
|
||||
entries, err := os.ReadDir(cfg.Pipeline.Workspace.Root)
|
||||
if err != nil || len(entries) != 0 {
|
||||
@@ -109,5 +124,17 @@ func TestRemoteAudioInspectionAgreesWithPreparation(t *testing.T) {
|
||||
if (err != nil) != collision {
|
||||
t.Fatalf("prepare error: %v", err)
|
||||
}
|
||||
if !collision {
|
||||
var keys []string
|
||||
for _, input := range m.Inputs {
|
||||
if input.Kind == "audio" {
|
||||
keys = append(keys, input.S3Key)
|
||||
}
|
||||
}
|
||||
sort.Strings(keys)
|
||||
if !slices.Equal(check.Keys, keys) {
|
||||
t.Fatalf("inspection keys %v, prepared keys %v", check.Keys, keys)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user