Make product checks additive
This commit is contained in:
@@ -41,7 +41,7 @@ func TestValidStableVersion(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckCapturesCandidateAndCallsValidationOnce(t *testing.T) {
|
||||
func TestCheckCapturesCandidateAndCallsAdditionalChecksOnce(t *testing.T) {
|
||||
repository := newRepository(t, "# Example Product v1.2.3\n\nRelease note.\n")
|
||||
calls := 0
|
||||
var seen Candidate
|
||||
@@ -49,7 +49,7 @@ func TestCheckCapturesCandidateAndCallsValidationOnce(t *testing.T) {
|
||||
RepositoryDir: repository,
|
||||
Product: "Example Product",
|
||||
Version: testVersion,
|
||||
Validate: func(_ context.Context, captured Candidate) error {
|
||||
AdditionalChecks: func(_ context.Context, captured Candidate) error {
|
||||
calls++
|
||||
seen = captured
|
||||
return nil
|
||||
@@ -174,7 +174,7 @@ func TestCheckRequiresMatchingCommittedNote(t *testing.T) {
|
||||
RepositoryDir: repository,
|
||||
Product: "Example Product",
|
||||
Version: testVersion,
|
||||
Validate: func(context.Context, Candidate) error {
|
||||
AdditionalChecks: func(context.Context, Candidate) error {
|
||||
called = true
|
||||
return nil
|
||||
},
|
||||
@@ -230,7 +230,7 @@ func TestCheckRequiresMainBranchAndUnusedTag(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestCheckStopsOnCallbackFailure(t *testing.T) {
|
||||
func TestCheckStopsOnAdditionalCheckFailure(t *testing.T) {
|
||||
repository := newRepository(t, "# Example Product v1.2.3\n")
|
||||
want := errors.New("selected check failed")
|
||||
calls := 0
|
||||
@@ -238,7 +238,7 @@ func TestCheckStopsOnCallbackFailure(t *testing.T) {
|
||||
RepositoryDir: repository,
|
||||
Product: "Example Product",
|
||||
Version: testVersion,
|
||||
Validate: func(context.Context, Candidate) error {
|
||||
AdditionalChecks: func(context.Context, Candidate) error {
|
||||
calls++
|
||||
return want
|
||||
},
|
||||
@@ -287,7 +287,7 @@ func TestCheckRechecksHeadAndWorktreeAfterCallback(t *testing.T) {
|
||||
RepositoryDir: repository,
|
||||
Product: "Example Product",
|
||||
Version: testVersion,
|
||||
Validate: func(context.Context, Candidate) error {
|
||||
AdditionalChecks: func(context.Context, Candidate) error {
|
||||
test.validate(t, repository)
|
||||
return nil
|
||||
},
|
||||
@@ -305,7 +305,7 @@ func TestCheckRechecksLocalTagAfterCallback(t *testing.T) {
|
||||
RepositoryDir: repository,
|
||||
Product: "Example Product",
|
||||
Version: testVersion,
|
||||
Validate: func(context.Context, Candidate) error {
|
||||
AdditionalChecks: func(context.Context, Candidate) error {
|
||||
gitRun(t, repository, "tag", testVersion)
|
||||
return nil
|
||||
},
|
||||
@@ -316,7 +316,7 @@ func TestCheckRechecksLocalTagAfterCallback(t *testing.T) {
|
||||
}
|
||||
|
||||
func validRequest(repository string) Request {
|
||||
return Request{RepositoryDir: repository, Product: "Example Product", Version: testVersion, Validate: func(context.Context, Candidate) error { return nil }}
|
||||
return Request{RepositoryDir: repository, Product: "Example Product", Version: testVersion, AdditionalChecks: func(context.Context, Candidate) error { return nil }}
|
||||
}
|
||||
|
||||
func newRepository(t *testing.T, note string) string {
|
||||
|
||||
Reference in New Issue
Block a user