also looking at this
fix(ci): land the lock-file repair instead of describing it
#1408
6 files
+193
-15
| @@ -104,7 +104,7 @@ describe('fix attempts', () => { | ||
| 104 | 104 | log: LOCKFILE_LOG, |
| 105 | 105 | regenerateLockfile: async () => { |
| 106 | 106 | regenerated = true |
| 107 | return true | |
| 107 | return { regenerated: true, pushed: true } | |
| 108 | 108 | }, |
| 109 | 109 | }) |
| 110 | 110 | |
| @@ -130,7 +130,7 @@ describe('fix attempts', () => { | ||
| 130 | 130 | failsOnBase: true, |
| 131 | 131 | regenerateLockfile: async () => { |
| 132 | 132 | regenerated = true |
| 133 | return true | |
| 133 | return { regenerated: true, pushed: true } | |
| 134 | 134 | }, |
| 135 | 135 | }) |
| 136 | 136 | |
| @@ -161,3 +161,63 @@ describe('fix attempts', () => { | ||
| 161 | 161 | expect(outcome.report).toContain('error TS2322') |
| 162 | 162 | }) |
| 163 | 163 | }) |
| 164 | ||
| 165 | describe('the lock-file repair reports what it actually did', () => { | |
| 166 | const base = { workspace: '/tmp', baseBranch: 'main' } | |
| 167 | ||
| 168 | it('failure case - a regenerated file that was not pushed is not a fix', async () => { | |
| 169 | // The report claimed "and pushed the result" long before anything pushed | |
| 170 | // anything. A file rewritten in a workspace about to be discarded has | |
| 171 | // repaired nothing, so the run is still red. | |
| 172 | const outcome = await attemptFix({ | |
| 173 | ...base, | |
| 174 | log: LOCKFILE_LOG, | |
| 175 | regenerateLockfile: async () => ({ regenerated: true, pushed: false }), | |
| 176 | }) | |
| 177 | ||
| 178 | expect(outcome.fixed).toBe(false) | |
| 179 | expect(outcome.report).toContain('could not push') | |
| 180 | expect(outcome.report).not.toContain('pushed the result') | |
| 181 | }) | |
| 182 | ||
| 183 | it('success case - a pushed file is a fix, and says so', async () => { | |
| 184 | const outcome = await attemptFix({ | |
| 185 | ...base, | |
| 186 | log: LOCKFILE_LOG, | |
| 187 | regenerateLockfile: async () => ({ regenerated: true, pushed: true }), | |
| 188 | }) | |
| 189 | ||
| 190 | expect(outcome.fixed).toBe(true) | |
| 191 | expect(outcome.report).toContain('pushed the result') | |
| 192 | }) | |
| 193 | ||
| 194 | it('failure case - a failed install is reported as such', async () => { | |
| 195 | const outcome = await attemptFix({ | |
| 196 | ...base, | |
| 197 | log: LOCKFILE_LOG, | |
| 198 | regenerateLockfile: async () => ({ regenerated: false, pushed: false }), | |
| 199 | }) | |
| 200 | ||
| 201 | expect(outcome.fixed).toBe(false) | |
| 202 | expect(outcome.report).toContain('did not succeed') | |
| 203 | }) | |
| 204 | ||
| 205 | it('success case - a dry run diagnoses without touching the workspace', async () => { | |
| 206 | // `--dry-run` used to regenerate lock files on disk regardless, because | |
| 207 | // the callback was passed unconditionally and never consulted the flag. | |
| 208 | let called = false | |
| 209 | const outcome = await attemptFix({ | |
| 210 | ...base, | |
| 211 | log: LOCKFILE_LOG, | |
| 212 | dryRun: true, | |
| 213 | regenerateLockfile: async () => { | |
| 214 | called = true | |
| 215 | return { regenerated: true, pushed: true } | |
| 216 | }, | |
| 217 | }) | |
| 218 | ||
| 219 | expect(called).toBe(false) | |
| 220 | expect(outcome.fixed).toBe(false) | |
| 221 | expect(outcome.report).toContain('dry run') | |
| 222 | }) | |
| 223 | }) | |