Commit d9d1f94513

d9d1f9451317ee179151864674022ad81176210b

parent: 6f729def95

Unsigned

cmc <hello@cleberg.net> · 2026-09-07 17:36 UTC

MR lifecycle tests: load issues four reads (!76)

mr revisions joined show, diff and threads in !72; the GET counts in MRLifecycleActionTests assumed three.

Layout: unified · split

gitbayTests/MRLifecycleTests.swift +11 −10
@@ -121,9 +121,10 @@ struct MRLifecycleActionTests {
121121 """))
122122 }
123123
124 /// `load()` issues three GETs: `mr show`, `mr diff`, `mr threads`.
125 /// `loaded()` runs it once (3 GETs, the last two unstubbed and failed),
126 /// so a reload after a write brings the total to 6.
124 /// `load()` issues four GETs: `mr show`, `mr diff`, `mr threads`,
125 /// `mr revisions`. `loaded()` runs it once (4 GETs, the last three
126 /// unstubbed and failed), so a reload after a write brings the total
127 /// to 8.
127128 private func gets(_ box: StubProtocol.Box) -> Int {
128129 box.seen.count { $0.method == "GET" }
129130 }
@@ -134,14 +135,14 @@ struct MRLifecycleActionTests {
134135 await model.setDraft(true)
135136 var write = try #require(box.seen.first { $0.method == "POST" })
136137 #expect(try argvOf(write) == ["mr", "draft", "krz/gitbay", "7"])
137 #expect(gets(box) == 6)
138 #expect(gets(box) == 8)
138139
139140 let (model2, box2) = try await loaded()
140141 ok(box2)
141142 await model2.setDraft(false)
142143 write = try #require(box2.seen.first { $0.method == "POST" })
143144 #expect(try argvOf(write) == ["mr", "ready", "krz/gitbay", "7"])
144 #expect(gets(box2) == 6)
145 #expect(gets(box2) == 8)
145146 }
146147
147148 @Test func retargetPassesTheBranchPositionally() async throws {
@@ -150,7 +151,7 @@ struct MRLifecycleActionTests {
150151 await model.retarget(to: "release")
151152 let write = try #require(box.seen.first { $0.method == "POST" })
152153 #expect(try argvOf(write) == ["mr", "retarget", "krz/gitbay", "7", "release"])
153 #expect(gets(box) == 6)
154 #expect(gets(box) == 8)
154155 }
155156
156157 /// `mr review request` is a THREE-word path. Two words posts a
@@ -162,7 +163,7 @@ struct MRLifecycleActionTests {
162163 let write = try #require(box.seen.first { $0.method == "POST" })
163164 #expect(try argvOf(write)
164165 == ["mr", "review", "request", "krz/gitbay", "7", "--add", "rae"])
165 #expect(gets(box) == 6)
166 #expect(gets(box) == 8)
166167 }
167168
168169 @Test func removingAReviewRequestUsesRemoveNotAdd() async throws {
@@ -172,7 +173,7 @@ struct MRLifecycleActionTests {
172173 let write = try #require(box.seen.first { $0.method == "POST" })
173174 #expect(try argvOf(write)
174175 == ["mr", "review", "request", "krz/gitbay", "7", "--remove", "rae"])
175 #expect(gets(box) == 6)
176 #expect(gets(box) == 8)
176177 }
177178
178179 @Test func branchesComeFromRepoRefs() async throws {
@@ -195,8 +196,8 @@ struct MRLifecycleActionTests {
195196 #expect(model.actionError?.isEmpty == false)
196197 #expect(model.working == false)
197198 // A refusal throws before `perform` reaches `load()`: still the
198 // 3 GETs from `loaded()`, none from a reload.
199 #expect(gets(box) == 3)
199 // 4 GETs from `loaded()`, none from a reload.
200 #expect(gets(box) == 4)
200201 }
201202}
202203