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

100% Statements 20/20
66.66% Branches 2/3
100% Functions 1/1
100% Lines 20/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 1x 1x  
import {handler} from '@feasibleone/blong';
 
/**
 * sqlTableDrop — drops the `item` 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 sqlTableDrop(
            _params: Record<string, never>,
            _$meta: Record<string, unknown>,
        ): Promise<{table: string; dropped: boolean}> {
            const existed = await this.config?.context?.queryBuilder?.schema.hasTable('item');
            if (existed) {
                await this.config?.context?.queryBuilder?.schema.dropTable('item');
            }
            return {table: 'item', dropped: existed ?? false};
        },
);