| @@ -121,18 +121,27 @@ struct MRLifecycleActionTests { |
| 121 | 121 | """)) |
| 122 | 122 | } |
| 123 | 123 | |
| 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. |
| 127 | private func gets(_ box: StubProtocol.Box) -> Int { |
| 128 | box.seen.count { $0.method == "GET" } |
| 129 | } |
| 130 | |
| 124 | 131 | @Test func markingDraftAndReadyAreDifferentCommands() async throws { |
| 125 | 132 | let (model, box) = try await loaded() |
| 126 | 133 | ok(box) |
| 127 | 134 | await model.setDraft(true) |
| 128 | 135 | var write = try #require(box.seen.first { $0.method == "POST" }) |
| 129 | 136 | #expect(try argvOf(write) == ["mr", "draft", "krz/gitbay", "7"]) |
| 137 | #expect(gets(box) == 6) |
| 130 | 138 | |
| 131 | 139 | let (model2, box2) = try await loaded() |
| 132 | 140 | ok(box2) |
| 133 | 141 | await model2.setDraft(false) |
| 134 | 142 | write = try #require(box2.seen.first { $0.method == "POST" }) |
| 135 | 143 | #expect(try argvOf(write) == ["mr", "ready", "krz/gitbay", "7"]) |
| 144 | #expect(gets(box2) == 6) |
| 136 | 145 | } |
| 137 | 146 | |
| 138 | 147 | @Test func retargetPassesTheBranchPositionally() async throws { |
| @@ -141,6 +150,7 @@ struct MRLifecycleActionTests { |
| 141 | 150 | await model.retarget(to: "release") |
| 142 | 151 | let write = try #require(box.seen.first { $0.method == "POST" }) |
| 143 | 152 | #expect(try argvOf(write) == ["mr", "retarget", "krz/gitbay", "7", "release"]) |
| 153 | #expect(gets(box) == 6) |
| 144 | 154 | } |
| 145 | 155 | |
| 146 | 156 | /// `mr review request` is a THREE-word path. Two words posts a |
| @@ -152,6 +162,7 @@ struct MRLifecycleActionTests { |
| 152 | 162 | let write = try #require(box.seen.first { $0.method == "POST" }) |
| 153 | 163 | #expect(try argvOf(write) |
| 154 | 164 | == ["mr", "review", "request", "krz/gitbay", "7", "--add", "rae"]) |
| 165 | #expect(gets(box) == 6) |
| 155 | 166 | } |
| 156 | 167 | |
| 157 | 168 | @Test func removingAReviewRequestUsesRemoveNotAdd() async throws { |
| @@ -161,6 +172,7 @@ struct MRLifecycleActionTests { |
| 161 | 172 | let write = try #require(box.seen.first { $0.method == "POST" }) |
| 162 | 173 | #expect(try argvOf(write) |
| 163 | 174 | == ["mr", "review", "request", "krz/gitbay", "7", "--remove", "rae"]) |
| 175 | #expect(gets(box) == 6) |
| 164 | 176 | } |
| 165 | 177 | |
| 166 | 178 | @Test func branchesComeFromRepoRefs() async throws { |
| @@ -182,6 +194,9 @@ struct MRLifecycleActionTests { |
| 182 | 194 | await model.retarget(to: "release") |
| 183 | 195 | #expect(model.actionError?.isEmpty == false) |
| 184 | 196 | #expect(model.working == false) |
| 197 | // A refusal throws before `perform` reaches `load()`: still the |
| 198 | // 3 GETs from `loaded()`, none from a reload. |
| 199 | #expect(gets(box) == 3) |
| 185 | 200 | } |
| 186 | 201 | } |
| 187 | 202 | |