mirror of
https://github.com/imjasonh/infinite-git
synced 2026-07-18 14:55:01 +00:00
Remove redundant TestGoGet (clone-only test)
TestGoGet (3 independent clones) is strictly weaker than both TestGoGetE2E (real go get) and TestGoGetPull (clone + pulls with go build verification). Remove it to reduce duplication. Remaining tests: - TestGoGetE2E: real `go get` on :80 (skips without privileges) - TestGoGetPull: git clone + pull fallback (always runs) - TestGoGetDiscovery: ?go-get=1 meta tag https://claude.ai/code/session_01HpvELk7HnbJoXEUjqHP7SU
This commit is contained in:
parent
89734da0dd
commit
77b616e05f
1 changed files with 4 additions and 75 deletions
|
|
@ -132,81 +132,10 @@ func TestGoGetE2E(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestGoGet clones the infinite-go server repeatedly using git (which is what
|
// TestGoGetPull clones and then pulls repeatedly using the git CLI,
|
||||||
// `go get` does under the hood with GOPROXY=direct) and verifies that each
|
// verifying each pull produces a buildable Go package with a unique PullTime.
|
||||||
// clone produces a valid, buildable Go package with a unique PullTime.
|
// This always runs (no privileged port needed) as a fallback for environments
|
||||||
func TestGoGet(t *testing.T) {
|
// where TestGoGetE2E is skipped.
|
||||||
goBin, err := exec.LookPath("go")
|
|
||||||
if err != nil {
|
|
||||||
t.Skip("go binary not found in PATH")
|
|
||||||
}
|
|
||||||
gitBin, err := exec.LookPath("git")
|
|
||||||
if err != nil {
|
|
||||||
t.Skip("git binary not found in PATH")
|
|
||||||
}
|
|
||||||
|
|
||||||
modulePath := "example.com/infinite-go"
|
|
||||||
ts := newGoTestServer(t, modulePath)
|
|
||||||
|
|
||||||
var pullTimes []string
|
|
||||||
|
|
||||||
for i := 0; i < 3; i++ {
|
|
||||||
cloneDir := t.TempDir()
|
|
||||||
|
|
||||||
// Clone via git — this is exactly what `go get` with GOPROXY=direct does.
|
|
||||||
cmd := exec.Command(gitBin, "clone", ts.URL, cloneDir)
|
|
||||||
out, err := cmd.CombinedOutput()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("git clone #%d failed: %v\noutput: %s", i+1, err, out)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify go.mod has the right module path.
|
|
||||||
goMod, err := os.ReadFile(filepath.Join(cloneDir, "go.mod"))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("clone #%d: failed to read go.mod: %v", i+1, err)
|
|
||||||
}
|
|
||||||
if !strings.Contains(string(goMod), fmt.Sprintf("module %s", modulePath)) {
|
|
||||||
t.Fatalf("clone #%d: go.mod has wrong module path: %s", i+1, goMod)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify the package builds.
|
|
||||||
cmd = exec.Command(goBin, "build", "./...")
|
|
||||||
cmd.Dir = cloneDir
|
|
||||||
out, err = cmd.CombinedOutput()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("clone #%d: go build failed: %v\noutput: %s", i+1, err, out)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read pulltime.go and extract the PullTime declaration.
|
|
||||||
data, err := os.ReadFile(filepath.Join(cloneDir, "pulltime.go"))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("clone #%d: failed to read pulltime.go: %v", i+1, err)
|
|
||||||
}
|
|
||||||
for _, line := range strings.Split(string(data), "\n") {
|
|
||||||
if strings.Contains(line, "var PullTime") {
|
|
||||||
pullTimes = append(pullTimes, strings.TrimSpace(line))
|
|
||||||
t.Logf("clone #%d: %s", i+1, strings.TrimSpace(line))
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(pullTimes) != 3 {
|
|
||||||
t.Fatalf("expected 3 PullTime values, got %d", len(pullTimes))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Every clone must produce a unique PullTime.
|
|
||||||
seen := make(map[string]bool)
|
|
||||||
for i, pt := range pullTimes {
|
|
||||||
if seen[pt] {
|
|
||||||
t.Errorf("clone #%d returned duplicate PullTime: %s", i+1, pt)
|
|
||||||
}
|
|
||||||
seen[pt] = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestGoGetPull verifies that git pull on an already-cloned repo also
|
|
||||||
// produces a new PullTime.
|
|
||||||
func TestGoGetPull(t *testing.T) {
|
func TestGoGetPull(t *testing.T) {
|
||||||
goBin, err := exec.LookPath("go")
|
goBin, err := exec.LookPath("go")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue