Flatten session inspection error aggregation
This commit is contained in:
@@ -233,6 +233,49 @@ func TestPublishedOutputInspectionKeepsCarriedIdentityWithoutPayloadReads(t *tes
|
||||
}
|
||||
}
|
||||
|
||||
type inspectionFailingStore struct {
|
||||
storage.ObjectStore
|
||||
failures map[string]error
|
||||
}
|
||||
|
||||
func (s inspectionFailingStore) Exists(_ context.Context, key string) (bool, error) {
|
||||
return false, s.failures[key]
|
||||
}
|
||||
|
||||
func TestPublishedOutputInspectionRetainsMultipleLookupFailures(t *testing.T) {
|
||||
cfg := restorePlanConfig(t)
|
||||
rules := []config.PublishOutputRule{
|
||||
{Source: "narratio.transcript.final_trimmed", Dest: "first.json"},
|
||||
{Source: "narratio.transcript.final", Dest: "second.json"},
|
||||
}
|
||||
cfg.ArtifactCatalog = &config.ArtifactCatalog{PublishOutputs: rules}
|
||||
fake := &storage.FakeBackend{}
|
||||
current := seedCommittedRestoreSnapshot(t, cfg, fake, "20260519T010203Z-a1b2c3d4", nil)
|
||||
failures := []error{&os.PathError{Op: "first", Path: "one", Err: os.ErrPermission}, &os.PathError{Op: "second", Path: "two", Err: os.ErrNotExist}}
|
||||
store := inspectionFailingStore{ObjectStore: fake, failures: map[string]error{}}
|
||||
for i, rule := range rules {
|
||||
key := artifacts.S3RunRelativeDestinationKey(artifacts.S3RunPrefix(current.SessionPrefix, current.RunID), "published/"+rule.Dest)
|
||||
current.Commit.Artifacts = append(current.Commit.Artifacts, artifacts.RemoteArtifact{Type: artifacts.RemoteArtifactTypePublishedOutput, Source: rule.Source, DestinationKey: key})
|
||||
store.failures[key] = failures[i]
|
||||
}
|
||||
outputs, err := inspectPublishedOutputs(context.Background(), cfg, store, nil, current, nil, true, "current")
|
||||
if len(outputs) != len(rules) {
|
||||
t.Fatalf("outputs = %#v", outputs)
|
||||
}
|
||||
for i, output := range outputs {
|
||||
if output.Source != rules[i].Source || output.State != "error" || output.Error != failures[i].Error() {
|
||||
t.Fatalf("output %d = %#v", i, output)
|
||||
}
|
||||
if !errors.Is(err, failures[i]) {
|
||||
t.Fatalf("missing cause %v in %v", failures[i], err)
|
||||
}
|
||||
}
|
||||
var pathErr *os.PathError
|
||||
if !errors.As(err, &pathErr) || pathErr != failures[0] || err.Error() != failures[0].Error()+"\n"+failures[1].Error() {
|
||||
t.Fatalf("ordered errors = %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSessionStateCommandsLeaveManifestUnchanged(t *testing.T) {
|
||||
pipeline, campaign, session := writeValidConfigFiles(t, t.TempDir())
|
||||
cfg, err := config.LoadWithSessionOptions(pipeline, campaign, session, config.SessionLoadOptions{})
|
||||
|
||||
Reference in New Issue
Block a user