All files / blong-int-adapter/mysql/adapter/sql sqlUnitDrop.ts

90% Statements 18/20
50% Branches 2/4
100% Functions 1/1
90% Lines 18/20

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 211x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x  
import {handler} from '@feasibleone/blong';
 
/**
 * sqlUnitDrop — drops the `unit` test table from the blong-integration
 * database if it exists.
 * This handler is called from integration tests to clean up after tests.
 */
export default handler(
    () =>
        async function sqlUnitDrop(
            _params: Record<string, never>,
            _$meta: Record<string, unknown>,
        ): Promise<{table: string; dropped: boolean}> {
            const existed = await this.config?.context?.queryBuilder?.schema.hasTable('unit');
            if (existed) {
                await this.config?.context?.queryBuilder?.schema.dropTable('unit');
            }
            return {table: 'unit', dropped: existed ?? false};
        },
);