Apply module scope to file validation checks
This commit is contained in:
37
validation_scope_test.go
Normal file
37
validation_scope_test.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package releasekit
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/ReleaseKit/internal/validation"
|
||||
)
|
||||
|
||||
func TestSharedFileFailureKeepsPublicIdentityPathAndCause(t *testing.T) {
|
||||
cause := errors.New("selected file is missing")
|
||||
err := convertValidationError(&validation.Failure{
|
||||
Check: validation.SharedFiles,
|
||||
Findings: []validation.Finding{{
|
||||
Path: "shared/NOTICE.md",
|
||||
Message: "selected shared file is not present in the committed tree",
|
||||
}},
|
||||
Cause: cause,
|
||||
})
|
||||
var failure *ValidationError
|
||||
if !errors.As(err, &failure) {
|
||||
t.Fatalf("converted error = %T, want *ValidationError", err)
|
||||
}
|
||||
if failure.Check != ValidationCheck("shared-files") {
|
||||
t.Fatalf("validation check = %q, want shared-files", failure.Check)
|
||||
}
|
||||
if len(failure.Findings) != 1 || failure.Findings[0].Path != "shared/NOTICE.md" {
|
||||
t.Fatalf("validation findings = %#v, want selected shared path", failure.Findings)
|
||||
}
|
||||
if !errors.Is(err, cause) {
|
||||
t.Fatalf("converted error %v does not preserve its cause", err)
|
||||
}
|
||||
if !strings.Contains(err.Error(), "shared-files") || !strings.Contains(err.Error(), "shared/NOTICE.md") {
|
||||
t.Fatalf("validation presentation = %q, want check and path", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user