Retain discovered publication records when enumeration fails
This commit is contained in:
21
recovery_conversion_test.go
Normal file
21
recovery_conversion_test.go
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user