Inspect committed workspace files
This commit is contained in:
@@ -108,6 +108,52 @@ func TestCheckStopsBeforeProductAndBuildCallbacksWhenGoFormatFails(t *testing.T)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckReportsCommittedWorkspaceFilesWhenGoWorkspaceIsDisabled(t *testing.T) {
|
||||
t.Setenv("GOWORK", "off")
|
||||
repository := newRepository(t, "# Example Product v1.2.3\n\nRelease note.\n")
|
||||
writeTestFile(t, repository, "go.work", "go 1.25.0\n")
|
||||
writeTestFile(t, repository, "nested/go.work.sum", "workspace-sum\n")
|
||||
if err := os.MkdirAll(filepath.Join(repository, "linked"), 0o700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.Symlink("../go.work", filepath.Join(repository, "linked", "go.work")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
gitRun(t, repository, "add", "go.work", "nested/go.work.sum", "linked/go.work")
|
||||
gitRun(t, repository, "commit", "-m", "add workspace files")
|
||||
_, err := Check(context.Background(), Request{
|
||||
RepositoryDir: repository,
|
||||
Product: "Example Product",
|
||||
Version: testVersion,
|
||||
Validation: validation.Settings{ModuleDistribution: validation.ModuleDistributionSettings{
|
||||
WorkspaceFiles: true,
|
||||
}},
|
||||
})
|
||||
var failure *validation.Failure
|
||||
if !errors.As(err, &failure) || failure.Check != validation.WorkspaceFiles {
|
||||
t.Fatalf("Check error = %v, want workspace-files failure", err)
|
||||
}
|
||||
want := map[string]bool{
|
||||
"go.work": false,
|
||||
"linked/go.work": false,
|
||||
"nested/go.work.sum": false,
|
||||
}
|
||||
if len(failure.Findings) != len(want) {
|
||||
t.Fatalf("workspace findings = %#v, want %d paths", failure.Findings, len(want))
|
||||
}
|
||||
for _, finding := range failure.Findings {
|
||||
if _, ok := want[finding.Path]; !ok {
|
||||
t.Errorf("unexpected workspace path %q", finding.Path)
|
||||
}
|
||||
want[finding.Path] = true
|
||||
}
|
||||
for path, found := range want {
|
||||
if !found {
|
||||
t.Errorf("workspace path %q was not reported", path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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