diff --git a/internal/storage/storage.go b/internal/storage/storage.go index 1cc37812d..850055509 100644 --- a/internal/storage/storage.go +++ b/internal/storage/storage.go @@ -44,11 +44,11 @@ import ( // TaskRef identifies a task for storage setup. type TaskRef struct { - Owner, Repo string - IssueNumber int - Ecosystem string // "go", "node", "python", "rust", "custom" - WorktreeDir string // host path to the git worktree - PersistentStorage bool // if true, attach a per-repo Docker volume at /data/repo + Owner, Repo string + IssueNumber int + Ecosystem string // "go", "node", "python", "rust", "custom" + WorktreeDir string // host path to the git worktree + PersistentStorage bool // if true, attach a per-repo Docker volume at /data/repo } // Mount describes a container mount point. diff --git a/internal/storage/storage_test.go b/internal/storage/storage_test.go index e30316bce..83a943e56 100644 --- a/internal/storage/storage_test.go +++ b/internal/storage/storage_test.go @@ -3,6 +3,8 @@ package storage import ( "context" "encoding/json" + "fmt" + "go/format" "io" "net/http" "net/http/httptest" @@ -581,6 +583,48 @@ func dockerTestClient(t *testing.T, roundTrip func(*http.Request) (*http.Respons return cli } +// ── gofmt compliance ───────────────────────────────────────────────── + +func TestStorageDotGoIsGofmtClean(t *testing.T) { + // storage.go must be gofmt-clean so that CI checks (gofmt -l) pass. + // This test reads the source and feeds it through go/format.Source; + // if the output differs, the file is not canonical Go formatting. + src, err := os.ReadFile("storage.go") + if err != nil { + t.Fatal(err) + } + formatted, err := format.Source(src) + if err != nil { + t.Fatalf("storage.go is not valid Go: %v", err) + } + if string(formatted) != string(src) { + t.Errorf("storage.go is not gofmt-clean. diff:\n%s", diffBytes(src, formatted)) + } +} + +func diffBytes(a, b []byte) string { + linesA := strings.Split(string(a), "\n") + linesB := strings.Split(string(b), "\n") + var out strings.Builder + maxLine := len(linesA) + if len(linesB) > maxLine { + maxLine = len(linesB) + } + for i := 0; i < maxLine; i++ { + var lineA, lineB string + if i < len(linesA) { + lineA = linesA[i] + } + if i < len(linesB) { + lineB = linesB[i] + } + if lineA != lineB { + out.WriteString(fmt.Sprintf("-%s\n+%s\n", lineA, lineB)) + } + } + return out.String() +} + func dockerAPIPath(path string) string { if strings.HasPrefix(path, "/v1.55/") { return strings.TrimPrefix(path, "/v1.55")