Skip to content

Commit af42dfa

Browse files
committed
chore(vscode): move to central temp dir creation
- cleans up tem dir after every test
1 parent a94c4f0 commit af42dfa

19 files changed

+159
-171
lines changed

vscode/extension/tests/bad_setup.spec.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ import {
1616
test('missing LSP dependencies shows install prompt', async ({
1717
page,
1818
sharedCodeServer,
19+
tempDir,
1920
}) => {
20-
const tempDir = await fs.mkdtemp(
21-
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
22-
)
2321
const pythonEnvDir = path.join(tempDir, '.venv')
2422
const pythonDetails = await createVirtualEnvironment(pythonEnvDir)
2523
const custom_materializations = path.join(
@@ -60,10 +58,11 @@ test('missing LSP dependencies shows install prompt', async ({
6058
expect(await page.locator('text=Install').count()).toBeGreaterThanOrEqual(1)
6159
})
6260

63-
test('lineage, no sqlmesh found', async ({ page, sharedCodeServer }) => {
64-
const tempDir = await fs.mkdtemp(
65-
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
66-
)
61+
test('lineage, no sqlmesh found', async ({
62+
page,
63+
sharedCodeServer,
64+
tempDir,
65+
}) => {
6766
const pythonEnvDir = path.join(tempDir, '.venv')
6867
const pythonDetails = await createVirtualEnvironment(pythonEnvDir)
6968

@@ -95,10 +94,8 @@ test('lineage, no sqlmesh found', async ({ page, sharedCodeServer }) => {
9594
test.skip('check that the LSP runs correctly by opening lineage when looking at another file before not in workspace', async ({
9695
page,
9796
sharedCodeServer,
97+
tempDir,
9898
}) => {
99-
const tempDir = await fs.mkdtemp(
100-
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
101-
)
10299
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
103100
const pythonEnvDir = path.join(tempDir, '.venv')
104101
const pythonDetails = await createVirtualEnvironment(pythonEnvDir)

vscode/extension/tests/broken_project.spec.ts

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { test, expect } from './fixtures'
22
import fs from 'fs-extra'
3-
import os from 'os'
43
import path from 'path'
54
import {
65
openLineageView,
@@ -12,10 +11,11 @@ import {
1211
} from './utils'
1312
import { createPythonInterpreterSettingsSpecifier } from './utils_code_server'
1413

15-
test('bad project, double model', async ({ page, sharedCodeServer }) => {
16-
const tempDir = await fs.mkdtemp(
17-
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
18-
)
14+
test('bad project, double model', async ({
15+
tempDir,
16+
page,
17+
sharedCodeServer,
18+
}) => {
1919
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
2020

2121
// Read the customers.sql file
@@ -52,11 +52,9 @@ test('bad project, double model', async ({ page, sharedCodeServer }) => {
5252

5353
test('working project, then broken through adding double model, then refixed', async ({
5454
page,
55+
tempDir,
5556
sharedCodeServer,
5657
}) => {
57-
const tempDir = await fs.mkdtemp(
58-
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
59-
)
6058
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
6159

6260
await createPythonInterpreterSettingsSpecifier(tempDir)
@@ -149,11 +147,9 @@ test('working project, then broken through adding double model, then refixed', a
149147

150148
test('bad project, double model, then fixed', async ({
151149
page,
150+
tempDir,
152151
sharedCodeServer,
153152
}) => {
154-
const tempDir = await fs.mkdtemp(
155-
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
156-
)
157153
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
158154

159155
// Read the customers.sql file
@@ -218,10 +214,8 @@ test('bad project, double model, then fixed', async ({
218214
test('bad project, double model, check lineage', async ({
219215
page,
220216
sharedCodeServer,
217+
tempDir,
221218
}) => {
222-
const tempDir = await fs.mkdtemp(
223-
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
224-
)
225219
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
226220

227221
// Read the customers.sql file
@@ -248,10 +242,11 @@ test('bad project, double model, check lineage', async ({
248242
await page.waitForTimeout(500)
249243
})
250244

251-
test('bad model block, then fixed', async ({ page, sharedCodeServer }) => {
252-
const tempDir = await fs.mkdtemp(
253-
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
254-
)
245+
test('bad model block, then fixed', async ({
246+
page,
247+
sharedCodeServer,
248+
tempDir,
249+
}) => {
255250
// Copy over the sushi project
256251
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
257252
await createPythonInterpreterSettingsSpecifier(tempDir)

vscode/extension/tests/diagnostics.spec.ts

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import yaml from 'yaml'
1010
test('Workspace diagnostics show up in the diagnostics panel', async ({
1111
page,
1212
sharedCodeServer,
13+
tempDir,
1314
}) => {
14-
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'vscode-test-sushi-'))
1515
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
1616
await createPythonInterpreterSettingsSpecifier(tempDir)
1717

@@ -55,10 +55,8 @@ test.describe('Bad config.py/config.yaml file issues', () => {
5555
test('sqlmesh init, then corrupted config.yaml, bad yaml', async ({
5656
page,
5757
sharedCodeServer,
58+
tempDir,
5859
}) => {
59-
const tempDir = await fs.mkdtemp(
60-
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
61-
)
6260
await setup(tempDir)
6361
await createPythonInterpreterSettingsSpecifier(tempDir)
6462

@@ -135,10 +133,8 @@ test.describe('Bad config.py/config.yaml file issues', () => {
135133
test('sushi example, correct python, bad config', async ({
136134
page,
137135
sharedCodeServer,
136+
tempDir,
138137
}) => {
139-
const tempDir = await fs.mkdtemp(
140-
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
141-
)
142138
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
143139
await createPythonInterpreterSettingsSpecifier(tempDir)
144140

@@ -170,10 +166,11 @@ test.describe('Bad config.py/config.yaml file issues', () => {
170166
await expect(errorElement).toBeVisible({ timeout: 5000 })
171167
})
172168

173-
test('sushi example, bad config.py', async ({ page, sharedCodeServer }) => {
174-
const tempDir = await fs.mkdtemp(
175-
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
176-
)
169+
test('sushi example, bad config.py', async ({
170+
page,
171+
sharedCodeServer,
172+
tempDir,
173+
}) => {
177174
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
178175
await createPythonInterpreterSettingsSpecifier(tempDir)
179176

@@ -205,10 +202,7 @@ test.describe('Bad config.py/config.yaml file issues', () => {
205202
})
206203

207204
test.describe('Diagnostics for bad SQLMesh models', () => {
208-
test('duplicate model names', async ({ page, sharedCodeServer }) => {
209-
const tempDir = await fs.mkdtemp(
210-
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
211-
)
205+
test('duplicate model names', async ({ page, sharedCodeServer, tempDir }) => {
212206
// Copy over the sushi project
213207
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
214208
await createPythonInterpreterSettingsSpecifier(tempDir)
@@ -246,10 +240,7 @@ test.describe('Diagnostics for bad SQLMesh models', () => {
246240
.isVisible({ timeout: 5_000 })
247241
})
248242

249-
test('bad model block', async ({ page, sharedCodeServer }) => {
250-
const tempDir = await fs.mkdtemp(
251-
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
252-
)
243+
test('bad model block', async ({ page, sharedCodeServer, tempDir }) => {
253244
// Copy over the sushi project
254245
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
255246
await createPythonInterpreterSettingsSpecifier(tempDir)
@@ -289,11 +280,11 @@ test.describe('Diagnostics for bad SQLMesh models', () => {
289280
})
290281

291282
test.describe('Diagnostics for bad audits', () => {
292-
test('bad audit block in audit', async ({ page, sharedCodeServer }) => {
293-
const tempDir = await fs.mkdtemp(
294-
path.join(os.tmpdir(), 'vscode-test-tcloud-'),
295-
)
296-
283+
test('bad audit block in audit', async ({
284+
page,
285+
sharedCodeServer,
286+
tempDir,
287+
}) => {
297288
// Copy over the sushi project
298289
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
299290
await createPythonInterpreterSettingsSpecifier(tempDir)

vscode/extension/tests/external_models.spec.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os from 'os'
21
import {
32
openServerPage,
43
SUSHI_SOURCE_PATH,
@@ -10,12 +9,9 @@ import fs from 'fs-extra'
109
import path from 'path'
1110

1211
test.describe('External model files trigger lsp', () => {
13-
test('external_models.yaml', async ({ page, sharedCodeServer }) => {
12+
test('external_models.yaml', async ({ page, sharedCodeServer, tempDir }) => {
1413
const file = 'external_models.yaml'
1514

16-
const tempDir = await fs.mkdtemp(
17-
path.join(os.tmpdir(), 'vscode-test-sushi-'),
18-
)
1915
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
2016

2117
// Assert external_models.yaml exists
@@ -38,12 +34,9 @@ test.describe('External model files trigger lsp', () => {
3834
await waitForLoadedSQLMesh(page)
3935
})
4036

41-
test('external_models.yml', async ({ page, sharedCodeServer }) => {
37+
test('external_models.yml', async ({ page, sharedCodeServer, tempDir }) => {
4238
const file = 'external_models.yml'
4339

44-
const tempDir = await fs.mkdtemp(
45-
path.join(os.tmpdir(), 'vscode-test-sushi-'),
46-
)
4740
await fs.copy(SUSHI_SOURCE_PATH, tempDir)
4841

4942
// Move external_models.yaml to external_models.yml

0 commit comments

Comments
 (0)