Release validation source bytes after checks
This commit is contained in:
@@ -90,7 +90,6 @@ func TestCheckGoFormatPreservesParserAndInspectionCauses(t *testing.T) {
|
||||
repositoryDir: t.TempDir(),
|
||||
entries: []git.TreeEntry{{Path: "missing.go", ObjectID: strings.Repeat("0", 40), Mode: "100644", Type: "blob"}},
|
||||
byPath: map[string]int{"missing.go": 0},
|
||||
blobs: make(map[string][]byte),
|
||||
}
|
||||
cleanupCandidateTree(t, tree)
|
||||
err := checkGoFormat(context.Background(), tree)
|
||||
@@ -104,6 +103,33 @@ func TestCheckGoFormatPreservesParserAndInspectionCauses(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestCheckGoFormatReportsEveryPathForRepeatedUnformattedContent(t *testing.T) {
|
||||
repository := newTreeRepository(t)
|
||||
contents := []byte("package app\nfunc value(){return}\n")
|
||||
writeTreeFile(t, repository, "first.go", contents)
|
||||
writeTreeFile(t, repository, "nested/second.go", contents)
|
||||
commit := commitCandidateTree(t, repository)
|
||||
tree, err := ReadCandidateTree(context.Background(), repository, commit)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cleanupCandidateTree(t, tree)
|
||||
|
||||
err = checkGoFormat(context.Background(), tree)
|
||||
var failure *Failure
|
||||
if !errors.As(err, &failure) || failure.Check != GoFormat {
|
||||
t.Fatalf("checkGoFormat() error = %v, want go-format findings", err)
|
||||
}
|
||||
if len(failure.Findings) != 2 || failure.Findings[0].Path != "first.go" || failure.Findings[1].Path != "nested/second.go" {
|
||||
t.Fatalf("findings = %#v, want both paths in tree order", failure.Findings)
|
||||
}
|
||||
first, _ := tree.Entry("first.go")
|
||||
second, _ := tree.Entry("nested/second.go")
|
||||
if first.ObjectID != second.ObjectID {
|
||||
t.Fatalf("fixture object IDs = %q and %q, want repeated content", first.ObjectID, second.ObjectID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunGoFormatIsOptionalAndStopsAfterFinding(t *testing.T) {
|
||||
repository := newTreeRepository(t)
|
||||
writeTreeFile(t, repository, "unformatted.go", []byte("package fixture\nfunc Value( ){return 1}\n"))
|
||||
|
||||
Reference in New Issue
Block a user