Skip to content

Commit a26502b

Browse files
committed
improve WP core update validation
1 parent b34cbe8 commit a26502b

1 file changed

Lines changed: 23 additions & 6 deletions

File tree

src/support/steps/query-monitor.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,29 @@ import {
2121
*/
2222
Given('WP is latest WP', async function (this: ICustomWorld) {
2323
const result = await wpWithOutput('core update');
24-
// Acceptable outcomes: already at latest, or successfully updated
25-
const success = !result.failed
26-
|| result.stdout.includes('WordPress is up to date')
27-
|| result.stdout.includes('Success');
28-
if (!success) {
29-
throw new Error(`Failed to update WordPress core: ${result.stderr}`);
24+
25+
if (result.failed) {
26+
throw new Error(
27+
`Failed to update WordPress core.\nSTDOUT:\n${result.stdout}\nSTDERR:\n${result.stderr}`
28+
);
29+
}
30+
31+
const stdout = result.stdout ?? '';
32+
const isAlreadyUpToDate = stdout.includes('WordPress is up to date');
33+
const isUpdateSuccess = stdout.includes('Success');
34+
35+
if (!isAlreadyUpToDate && !isUpdateSuccess) {
36+
throw new Error(
37+
`Unexpected output from "wp core update".\nSTDOUT:\n${stdout}\nSTDERR:\n${result.stderr}`
38+
);
39+
}
40+
41+
const updateDbResult = await wpWithOutput('core update-db');
42+
43+
if (updateDbResult.failed) {
44+
throw new Error(
45+
`Failed to run "wp core update-db".\nSTDOUT:\n${updateDbResult.stdout}\nSTDERR:\n${updateDbResult.stderr}`
46+
);
3047
}
3148
});
3249

0 commit comments

Comments
 (0)