Check committed Go formatting
This commit is contained in:
@@ -78,6 +78,36 @@ func TestCheckCapturesCandidateAndCallsAdditionalChecksOnce(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckStopsBeforeProductAndBuildCallbacksWhenGoFormatFails(t *testing.T) {
|
||||
repository := newRepository(t, "# Example Product v1.2.3\n\nRelease note.\n")
|
||||
writeTestFile(t, repository, "unformatted.go", "package candidate\nfunc Value( ) int{return 1}\n")
|
||||
gitRun(t, repository, "add", "unformatted.go")
|
||||
gitRun(t, repository, "commit", "-m", "add unformatted Go source")
|
||||
productCalls := 0
|
||||
buildCalls := 0
|
||||
_, err := Check(context.Background(), Request{
|
||||
RepositoryDir: repository,
|
||||
Product: "Example Product",
|
||||
Version: testVersion,
|
||||
Validation: validation.Settings{GoFormat: true},
|
||||
AdditionalChecks: func(context.Context, Candidate) error {
|
||||
productCalls++
|
||||
return nil
|
||||
},
|
||||
AfterValidate: func(context.Context, Candidate) error {
|
||||
buildCalls++
|
||||
return nil
|
||||
},
|
||||
})
|
||||
var failure *validation.Failure
|
||||
if !errors.As(err, &failure) || failure.Check != validation.GoFormat {
|
||||
t.Fatalf("Check error = %v, want go-format failure", err)
|
||||
}
|
||||
if productCalls != 0 || buildCalls != 0 {
|
||||
t.Fatalf("product callback calls = %d, build callback calls = %d; want neither after formatting failure", productCalls, buildCalls)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckRunsDefaultOfflineGoValidation(t *testing.T) {
|
||||
repository := newRepository(t, "# Example Product v1.2.3\n\nRelease note.\n")
|
||||
var output bytes.Buffer
|
||||
|
||||
Reference in New Issue
Block a user