test: failing repro for #49
This commit is contained in:
1 parent
ca92e24008
commit
af17f4cd66
2 files changed
+49
-5
No files matched your search
@@ -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.
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in new issue
Block a user