Files
releasekit/recovery_conversion_test.go

22 lines
995 B
Go
Raw Permalink Normal View History

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)
}
}