Skip to content

Commit

Permalink
Maybe fix flakey test
Browse files Browse the repository at this point in the history
  • Loading branch information
t1mmen committed Jan 1, 2025
1 parent eaea6ba commit ef4776a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/lib/templateManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ describe('TemplateManager', () => {
it('should handle sequential template operations', async () => {
const templates = await Promise.all(
[...Array(5)].map((_, i) =>
createTemplateWithFunc(`test-${i}-${testContext.timestamp}.sql`, `_sequence_test_${i}`)
createTemplateWithFunc(
`sequencetest-${i}-${testContext.timestamp}.sql`,
`_sequence_test_${i}`
)
)
);

Expand All @@ -214,6 +217,8 @@ describe('TemplateManager', () => {
expect(result.errors).toHaveLength(0);
}

await new Promise(resolve => setTimeout(resolve, 100));

const client = await connect();
try {
for (let i = 0; i < 5; i++) {
Expand All @@ -230,7 +235,7 @@ describe('TemplateManager', () => {
it('should generate unique timestamps for multiple templates', async () => {
const templates = await Promise.all(
[...Array(10)].map((_, i) =>
createTemplateWithFunc(`test-${i}-${testContext.timestamp}.sql`, `_${i}`)
createTemplateWithFunc(`timestamptest-${i}-${testContext.timestamp}.sql`, `_${i}`)
)
);

Expand All @@ -246,8 +251,8 @@ describe('TemplateManager', () => {
});

it('should handle mix of working and broken templates', async () => {
await createTemplateWithFunc(`test-good-${testContext.timestamp}.sql`, '_good');
await createTemplate(`test-bad-${testContext.timestamp}.sql`, 'INVALID SQL SYNTAX;');
await createTemplateWithFunc(`a-test-good-${testContext.timestamp}.sql`, '_good');
await createTemplate(`a-test-bad-${testContext.timestamp}.sql`, 'INVALID SQL SYNTAX;');

const manager = await TemplateManager.create(testContext.testDir);
const result = await manager.processTemplates({ apply: true });
Expand Down

0 comments on commit ef4776a

Please sign in to comment.