Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(client): Opt Out Of Providers (#13507)
* test/feat: add optIn options * test: add coverage for all in the _example * refactor: change to opt out * test: add more provider support * refactor: add missingProvider helper * temp: remove cockroachdb * Revert "temp: remove cockroachdb" This reverts commit fc84e59. * temp: opt out cockroach for metrics * fix: add cockroach and mongo to metrics * temp: remove other tests and add cockroach uri * Revert "temp: remove other tests and add cockroach uri" This reverts commit 9ab5b86. * ci/fix: add cockroachdb envs to client tests
- Loading branch information
Showing
30 changed files
with
455 additions
and
241 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
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
39 changes: 39 additions & 0 deletions
39
packages/client/tests/functional/_utils/checkMissingProviders.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,39 @@ | ||
import { getTestSuiteMeta, TestSuiteConfig } from './getTestSuiteInfo' | ||
import { Providers } from './providers' | ||
import { MatrixOptions } from './types' | ||
|
||
export type TestSuiteMeta = ReturnType<typeof getTestSuiteMeta> | ||
|
||
/** | ||
* Ensure that we are not forgetting to add a provider to the matrix unless we | ||
* explicitly opt out during in the {@link setupTestSuiteMatrix} creation. | ||
* @param suiteConfigs | ||
* @param suiteMeta | ||
* @param options | ||
*/ | ||
export function checkMissingProviders({ | ||
suiteConfig, | ||
suiteMeta, | ||
options, | ||
}: { | ||
suiteConfig: TestSuiteConfig[] | ||
suiteMeta: TestSuiteMeta | ||
options?: MatrixOptions | ||
}) { | ||
const suiteConfigProviders = suiteConfig.map(({ provider }) => provider) | ||
|
||
const missingProviders = Object.values(Providers).reduce((acc, provider) => { | ||
if (suiteConfigProviders.includes(provider)) return acc | ||
if (options?.optOut?.from.includes(provider)) return acc | ||
|
||
return [...acc, provider] | ||
}, [] as Providers[]) | ||
|
||
if (missingProviders.length) { | ||
throw new Error( | ||
`Test: '${suiteMeta.testDirName}' is missing providers '${missingProviders | ||
.map((x) => `'${x}'`) | ||
.join(', ')}' out out using options.optOut`, | ||
) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export enum Providers { | ||
SQLITE = 'sqlite', | ||
POSTGRESQL = 'postgresql', | ||
MYSQL = 'mysql', | ||
MONGODB = 'mongodb', | ||
COCKROACHDB = 'cockroachdb', | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Providers } from './providers' | ||
|
||
export type MatrixOptions = { | ||
optOut?: { | ||
from: `${Providers}`[] | ||
reason: string | ||
} | ||
skipDb?: boolean | ||
} |
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 |
---|---|---|
|
@@ -5,5 +5,8 @@ export default defineMatrix(() => [ | |
{ | ||
provider: 'postgresql', | ||
}, | ||
{ | ||
provider: 'cockroachdb', | ||
}, | ||
], | ||
]) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,8 @@ export default defineMatrix(() => [ | |
{ | ||
provider: 'mysql', | ||
}, | ||
{ | ||
provider: 'cockroachdb', | ||
}, | ||
], | ||
]) |
Oops, something went wrong.