diff --git a/lab/internal/readiness/repository_test.go b/lab/internal/readiness/repository_test.go index 8be730d..5c877c4 100644 --- a/lab/internal/readiness/repository_test.go +++ b/lab/internal/readiness/repository_test.go @@ -100,6 +100,10 @@ func repoFixture(t *testing.T) string { } } run("init", "-b", "main") + // No background git may still write under .git when t.TempDir cleans up. + run("config", "gc.auto", "0") + run("config", "maintenance.auto", "false") + run("config", "core.fsmonitor", "false") run("config", "user.email", "test@example.com") run("config", "user.name", "Fixture") for p, s := range map[string]string{"lab/go.mod": "module test\n\ngo 1.27.0\n", "lab/a.go": "package test\n", "README.md": "# Test\n", ".github/workflows/test.yml": "name: checks\n", ".env": "SECRET=do-not-collect\n"} { diff --git a/lab/plugins/gitlab/fakegitlab_test.go b/lab/plugins/gitlab/fakegitlab_test.go index e1d8f7f..a6dbc91 100644 --- a/lab/plugins/gitlab/fakegitlab_test.go +++ b/lab/plugins/gitlab/fakegitlab_test.go @@ -63,8 +63,8 @@ type fakeGitLab struct { hang bool bigPage bool // postFault creates the merge request a POST asks for, then loses the - // answer: "hang" never answers, "malformed" and "oversized" send a body - // the plugin refuses. + // answer: "drop" closes the connection without answering, "malformed" and + // "oversized" send a body the plugin refuses. postFault string release chan struct{} requests []seenRequest @@ -190,8 +190,15 @@ func (f *fakeGitLab) serve(w http.ResponseWriter, r *http.Request) { } f.mu.Unlock() switch fault { - case "hang": - hang = true + case "drop": + // The merge request is recorded above, so closing here loses only the + // answer, with no timing involved. + conn, _, err := http.NewResponseController(w).Hijack() + if err != nil { + panic(err) + } + conn.Close() + return case "malformed": w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusCreated) diff --git a/lab/plugins/gitlab/tools_test.go b/lab/plugins/gitlab/tools_test.go index ebc83d6..afbad17 100644 --- a/lab/plugins/gitlab/tools_test.go +++ b/lab/plugins/gitlab/tools_test.go @@ -273,15 +273,12 @@ func TestPublishDraftRefusesABlankTitle(t *testing.T) { // reported even when the create answer is lost. func TestPublishDraftRecoversALostAnswer(t *testing.T) { args := map[string]any{"project": "example/project", "headBranch": "forgecell/new", "base": "main", "title": "T", "body": "", "commit": headCommit} - for _, fault := range []string{"hang", "malformed", "oversized"} { + for _, fault := range []string{"drop", "malformed", "oversized"} { fake := newFakeGitLab(t) cfg, err := loadConfig(lookupFrom(fake.env(t))) if err != nil { t.Fatal(err) } - if fault == "hang" { - cfg.timeout = 50 * time.Millisecond - } h := &harness{fake: fake, f: &forge{c: newClient(cfg)}} fake.set(func(f *fakeGitLab) { f.postFault = fault }) got := decoded[contract.ForgePublished](t, h, "forge_publish_draft", args)