-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Save the number of successful, failed and total executions for …
…Test Run (no-changelog) (#12131)
- Loading branch information
1 parent
f7eb901
commit cc008f9
Showing
9 changed files
with
326 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/cli/src/databases/migrations/common/1736172058779-AddStatsColumnsToTestRun.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { MigrationContext, ReversibleMigration } from '@/databases/types'; | ||
|
||
const columns = ['totalCases', 'passedCases', 'failedCases'] as const; | ||
|
||
export class AddStatsColumnsToTestRun1736172058779 implements ReversibleMigration { | ||
async up({ escape, runQuery }: MigrationContext) { | ||
const tableName = escape.tableName('test_run'); | ||
const columnNames = columns.map((name) => escape.columnName(name)); | ||
|
||
// Values can be NULL only if the test run is new, otherwise they must be non-negative integers. | ||
// Test run might be cancelled or interrupted by unexpected error at any moment, so values can be either NULL or non-negative integers. | ||
for (const name of columnNames) { | ||
await runQuery(`ALTER TABLE ${tableName} ADD COLUMN ${name} INT CHECK( | ||
CASE | ||
WHEN status = 'new' THEN ${name} IS NULL | ||
WHEN status in ('cancelled', 'error') THEN ${name} IS NULL OR ${name} >= 0 | ||
ELSE ${name} >= 0 | ||
END | ||
)`); | ||
} | ||
} | ||
|
||
async down({ escape, runQuery }: MigrationContext) { | ||
const tableName = escape.tableName('test_run'); | ||
const columnNames = columns.map((name) => escape.columnName(name)); | ||
|
||
for (const name of columnNames) { | ||
await runQuery(`ALTER TABLE ${tableName} DROP COLUMN ${name}`); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.