34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import { inject as vitestInject } from "@suaveplan/testing/runner";
|
|
import type { PostgresConfig } from "@suaveplan/testing-integration-postgres";
|
|
|
|
interface IntegrationConfigs {
|
|
postgres: PostgresConfig;
|
|
}
|
|
|
|
export function inject<K extends keyof IntegrationConfigs>(
|
|
key: K
|
|
): IntegrationConfigs[K] {
|
|
const all = (vitestInject as (k: string) => IntegrationConfigs)(
|
|
"__integration_configs__"
|
|
);
|
|
return all[key];
|
|
}
|
|
|
|
export const postgresUnavailable: boolean = (() => {
|
|
try {
|
|
const failed = (vitestInject as (k: string) => string[] | undefined)(
|
|
"__integration_failed__"
|
|
);
|
|
if (failed === undefined) return true;
|
|
if (failed.includes("postgres")) return true;
|
|
const configs = (
|
|
vitestInject as (
|
|
k: string
|
|
) => Record<string, Record<string, unknown>> | undefined
|
|
)("__integration_configs__");
|
|
return configs === undefined || configs.postgres === undefined;
|
|
} catch {
|
|
return true;
|
|
}
|
|
})();
|