Expose validation errors through the root API
This commit is contained in:
@@ -109,6 +109,17 @@ func TestPublishFailedStandardSuiteSkipsAdditionalChecksAndTagCreation(t *testin
|
||||
if err == nil || !strings.Contains(err.Error(), "fixture standard suite failure") {
|
||||
t.Fatalf("Publish() error = %v, want fixture standard suite failure", err)
|
||||
}
|
||||
var validationError *releasekit.ValidationError
|
||||
if !errors.As(err, &validationError) || validationError.Check != "go-test" {
|
||||
t.Fatalf("Publish() error = %v, want a public go-test validation error", err)
|
||||
}
|
||||
var exitErr *exec.ExitError
|
||||
if !errors.As(err, &exitErr) {
|
||||
t.Fatalf("Publish() error = %v, want the Go process error preserved", err)
|
||||
}
|
||||
if !errors.Is(err, exitErr) {
|
||||
t.Fatal("Publish() error does not preserve the Go process error identity")
|
||||
}
|
||||
if checks != 0 || result.TagObject != "" || result.State != releasekit.PublicationNotAttempted {
|
||||
t.Fatalf("failed standard suite result=%#v additional checks=%d", result, checks)
|
||||
}
|
||||
@@ -122,6 +133,27 @@ func TestPublishFailedStandardSuiteSkipsAdditionalChecksAndTagCreation(t *testin
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckReturnsPublicValidationError(t *testing.T) {
|
||||
repo := newPublishFixture(t)
|
||||
t.Setenv("RELEASEKIT_FAIL_FIXTURE_SUITE", "1")
|
||||
_, err := releasekit.Check(context.Background(), releasekit.ReleaseRequest{
|
||||
RepositoryDir: repo.work,
|
||||
Product: "Sample App",
|
||||
Version: "v1.2.3",
|
||||
})
|
||||
var validationError *releasekit.ValidationError
|
||||
if !errors.As(err, &validationError) || validationError.Check != "go-test" {
|
||||
t.Fatalf("Check() error = %v, want a public go-test validation error", err)
|
||||
}
|
||||
var exitErr *exec.ExitError
|
||||
if !errors.As(err, &exitErr) {
|
||||
t.Fatalf("Check() error = %v, want the Go process error preserved", err)
|
||||
}
|
||||
if !errors.Is(err, exitErr) {
|
||||
t.Fatal("Check() error does not preserve the Go process error identity")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPublishAdditionalCheckFailurePreservesCauseAndPreventsTagCreation(t *testing.T) {
|
||||
repo := newPublishFixture(t)
|
||||
suiteRuns := filepath.Join(t.TempDir(), "suite-runs")
|
||||
@@ -140,6 +172,10 @@ func TestPublishAdditionalCheckFailurePreservesCauseAndPreventsTagCreation(t *te
|
||||
if !errors.Is(err, wantErr) {
|
||||
t.Fatalf("Publish() error = %v, want wrapped additional-check error", err)
|
||||
}
|
||||
var validationError *releasekit.ValidationError
|
||||
if errors.As(err, &validationError) {
|
||||
t.Fatalf("Publish() callback error was reclassified as validation failure: %v", err)
|
||||
}
|
||||
if runs, readErr := os.ReadFile(suiteRuns); readErr != nil || string(runs) != "ran\n" {
|
||||
t.Fatalf("standard suite runs = %q, error = %v; want one successful run", runs, readErr)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user