Retain discovered publication records when enumeration fails

This commit is contained in:
2026-11-02 22:41:18 +00:00
parent cd274512e7
commit 363f7cd513
7 changed files with 123 additions and 8 deletions

View File

@@ -0,0 +1,21 @@
package releasekit
import (
"errors"
"testing"
"go.maximumdirect.net/releasekit/internal/publish"
)
func TestPublicAttemptsRetainsPartialResultAndFailure(t *testing.T) {
failure := &publish.RecoveryError{Kind: "storage_enumeration"}
diagnostic := &publish.RecoveryError{Kind: "record_format", RecordPath: "broken.json"}
result, err := publicAttemptsResult(publish.AttemptsResult{
RecordDir: "records", Attempts: []publish.Attempt{{RecordPath: "good.json", Evidence: publish.Evidence{Tag: "v1.2.3"}}},
Diagnostics: []*publish.RecoveryError{diagnostic},
}, failure)
var typed *PublicationRecoveryError
if !errors.As(err, &typed) || typed.Kind != "storage_enumeration" || !errors.Is(err, failure) || len(result.Attempts) != 1 || result.Attempts[0].RecordPath != "good.json" || result.Attempts[0].Evidence.Tag != "v1.2.3" || len(result.Diagnostics) != 1 || !errors.Is(result.Diagnostics[0], diagnostic) {
t.Fatalf("facade lost partial results or cause: %#v, %v", result, err)
}
}