Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lab/internal/readiness/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"} {
Expand Down
15 changes: 11 additions & 4 deletions lab/plugins/gitlab/fakegitlab_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 1 addition & 4 deletions lab/plugins/gitlab/tools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading