Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: infer tmp directory name from test name everywhere #6566

Merged
merged 5 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/integration/commands/build/build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ describe.concurrent('command/build', () => {
})

test('should have version in NETLIFY_CLI_VERSION variable', async (t) => {
await withSiteBuilder('NETLIFY_CLI_VERSION-env', async (builder) => {
await withSiteBuilder(t, async (builder) => {
await builder
.withNetlifyToml({
config: {
Expand Down
26 changes: 13 additions & 13 deletions tests/integration/commands/dev/dev-forms-and-redirects.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { withSiteBuilder } from '../../utils/site-builder.ts'

describe.concurrent('commands/dev-forms-and-redirects', () => {
test('should return 404 when redirecting to a non existing function', async (t) => {
await withSiteBuilder('site-with-missing-function', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder.withNetlifyToml({
config: {
functions: { directory: 'functions' },
Expand All @@ -34,7 +34,7 @@ describe.concurrent('commands/dev-forms-and-redirects', () => {
})

test('should parse function query parameters using simple parsing', async (t) => {
await withSiteBuilder('site-with-multi-part-function', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder
.withNetlifyToml({
config: {
Expand Down Expand Up @@ -64,7 +64,7 @@ describe.concurrent('commands/dev-forms-and-redirects', () => {
})

test('should handle form submission', async (t) => {
await withSiteBuilder('site-with-form', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder
.withContentFile({
path: 'index.html',
Expand Down Expand Up @@ -129,7 +129,7 @@ describe.concurrent('commands/dev-forms-and-redirects', () => {
})

test('should handle form submission with a background function', async (t) => {
await withSiteBuilder('site-with-form-background-function', async (builder) => {
await withSiteBuilder(t, async (builder) => {
await builder
.withContentFile({
path: 'index.html',
Expand Down Expand Up @@ -163,7 +163,7 @@ describe.concurrent('commands/dev-forms-and-redirects', () => {
})

test('should not handle form submission when content type is `text/plain`', async (t) => {
await withSiteBuilder('site-with-form-text-plain', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder
.withContentFile({
path: 'index.html',
Expand Down Expand Up @@ -199,7 +199,7 @@ describe.concurrent('commands/dev-forms-and-redirects', () => {
})

test('should return existing local file even when rewrite matches when force=false', async (t) => {
await withSiteBuilder('site-with-shadowing-force-false', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder
.withContentFile({
path: 'foo.html',
Expand All @@ -225,7 +225,7 @@ describe.concurrent('commands/dev-forms-and-redirects', () => {
})

test('should return existing local file even when redirect matches when force=false', async (t) => {
await withSiteBuilder('site-with-shadowing-force-false', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder
.withContentFile({
path: 'foo.html',
Expand All @@ -251,7 +251,7 @@ describe.concurrent('commands/dev-forms-and-redirects', () => {
})

test('should ignore existing local file when redirect matches and force=true', async (t) => {
await withSiteBuilder('site-with-shadowing-force-true', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder
.withContentFile({
path: 'foo.html',
Expand Down Expand Up @@ -282,7 +282,7 @@ describe.concurrent('commands/dev-forms-and-redirects', () => {
})

test('should use existing file when rule contains file extension and force=false', async (t) => {
await withSiteBuilder('site-with-shadowing-file-extension-force-false', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder
.withContentFile({
path: 'foo.html',
Expand All @@ -309,7 +309,7 @@ describe.concurrent('commands/dev-forms-and-redirects', () => {
})

test('should redirect when rule contains file extension and force=true', async (t) => {
await withSiteBuilder('site-with-shadowing-file-extension-force-true', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder
.withContentFile({
path: 'foo.html',
Expand Down Expand Up @@ -340,7 +340,7 @@ describe.concurrent('commands/dev-forms-and-redirects', () => {
})

test('should redirect from sub directory to root directory', async (t) => {
await withSiteBuilder('site-with-shadowing-sub-to-root', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder
.withContentFile({
path: 'foo.html',
Expand Down Expand Up @@ -419,7 +419,7 @@ describe.concurrent('commands/dev-forms-and-redirects', () => {
await fs.writeFile(path.join(pluginDirectory, 'manifest.yml'), pluginManifest)
await fs.writeFile(path.join(pluginDirectory, 'index.js'), pluginSource)

await withSiteBuilder('site-with-custom-server-in-plugin', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder
.withNetlifyToml({
config: {
Expand Down Expand Up @@ -476,7 +476,7 @@ describe.concurrent('commands/dev-forms-and-redirects', () => {
await fs.writeFile(path.join(pluginDirectory, 'manifest.yml'), pluginManifest)
await fs.writeFile(path.join(pluginDirectory, 'index.js'), pluginSource)

await withSiteBuilder('site-with-custom-server-in-plugin', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder
.withNetlifyToml({
config: {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/commands/dev/dev-miscellaneous.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ describe.concurrent('commands/dev-miscellaneous', () => {
})

test('should fail in CI with multiple projects', async (t) => {
await withSiteBuilder('site-with-multiple-packages', async (builder) => {
await withSiteBuilder(t, async (builder) => {
await builder
.withPackageJson({ packageJson: { name: 'main', workspaces: ['*'] } })
.withPackageJson({ packageJson: { name: 'package1' }, pathPrefix: 'package1' })
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/commands/dev/dev.exec.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { callCli } from '../../utils/call-cli.js'
import { withSiteBuilder } from '../../utils/site-builder.ts'

test('should pass .env variables to exec command', async (t) => {
await withSiteBuilder('site-env-file', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder.withEnvFile({ env: { MY_SUPER_SECRET: 'SECRET' } })
await builder.buildAsync()

Expand Down
22 changes: 11 additions & 11 deletions tests/integration/commands/dev/responses.dev.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { withSiteBuilder } from '../../utils/site-builder.ts'

describe.concurrent('commands/responses.dev', () => {
test('should return index file when / is accessed', async (t) => {
await withSiteBuilder('site-with-index-file', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder.withContentFile({
path: 'index.html',
content: '<h1>⊂◉‿◉つ</h1>',
Expand All @@ -25,7 +25,7 @@ describe.concurrent('commands/responses.dev', () => {
})

test('should return user defined headers when / is accessed', async (t) => {
await withSiteBuilder('site-with-headers-on-root', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder.withContentFile({
path: 'index.html',
content: '<h1>⊂◉‿◉つ</h1>',
Expand All @@ -45,7 +45,7 @@ describe.concurrent('commands/responses.dev', () => {
})

test('should return user defined headers when non-root path is accessed', async (t) => {
await withSiteBuilder('site-with-headers-on-non-root', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder.withContentFile({
path: 'foo/index.html',
content: '<h1>⊂◉‿◉つ</h1>',
Expand All @@ -65,7 +65,7 @@ describe.concurrent('commands/responses.dev', () => {
})

test('should return response from a function with setTimeout', async (t) => {
await withSiteBuilder('site-with-set-timeout-function', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder.withNetlifyToml({ config: { functions: { directory: 'functions' } } }).withFunction({
path: 'timeout.js',
handler: async () => {
Expand Down Expand Up @@ -97,7 +97,7 @@ describe.concurrent('commands/responses.dev', () => {
})

test('should fail when no metadata is set for builder function', async (t) => {
await withSiteBuilder('site-with-misconfigured-builder-function', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder.withNetlifyToml({ config: { functions: { directory: 'functions' } } }).withFunction({
path: 'builder.js',
handler: async () => ({
Expand Down Expand Up @@ -125,7 +125,7 @@ describe.concurrent('commands/responses.dev', () => {
})

test('should serve function from a subdirectory', async (t) => {
await withSiteBuilder('site-with-from-subdirectory', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder.withNetlifyToml({ config: { functions: { directory: 'functions' } } }).withFunction({
path: path.join('echo', 'echo.js'),
handler: async (event) => ({
Expand All @@ -149,7 +149,7 @@ describe.concurrent('commands/responses.dev', () => {
})

test('should pass .env.development vars to function', async (t) => {
await withSiteBuilder('site-with-env-development', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder
.withNetlifyToml({ config: { functions: { directory: 'functions' } } })
.withEnvFile({ path: '.env.development', env: { ENV_DEV_TEST: 'FROM_DEV_FILE' } })
Expand Down Expand Up @@ -178,7 +178,7 @@ describe.concurrent('commands/responses.dev', () => {
})

test('should pass process env vars to function', async (t) => {
await withSiteBuilder('site-with-process-env', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder.withNetlifyToml({ config: { functions: { directory: 'functions' } } }).withFunction({
path: 'env.js',
handler: async () => ({
Expand All @@ -204,7 +204,7 @@ describe.concurrent('commands/responses.dev', () => {
})

test('should pass [build.environment] env vars to function', async (t) => {
await withSiteBuilder('site-with-build-environment', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder
.withNetlifyToml({
config: {
Expand Down Expand Up @@ -236,7 +236,7 @@ describe.concurrent('commands/responses.dev', () => {
})

test('[context.dev.environment] should override [build.environment]', async (t) => {
await withSiteBuilder('site-with-build-environment', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder
.withNetlifyToml({
config: {
Expand Down Expand Up @@ -264,7 +264,7 @@ describe.concurrent('commands/responses.dev', () => {
})

test('should inject env vars based on [dev].envFiles file order', async (t) => {
await withSiteBuilder('site-with-env-files', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder
.withNetlifyToml({
config: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ describe.concurrent('functions:create command', () => {
{ path: 'sites/site_id', method: 'patch', response: {} },
]

test('should create a new function directory when none is found', async () => {
await withSiteBuilder('site-with-no-functions-dir', async (builder) => {
test('should create a new function directory when none is found', async (t) => {
await withSiteBuilder(t, async (builder) => {
await builder.buildAsync()
await withMockApi(routes, async ({ apiUrl }) => {
const childProcess = execa(cliPath, ['functions:create'], getCLIOptions({ apiUrl, builder }))
Expand Down Expand Up @@ -71,8 +71,8 @@ describe.concurrent('functions:create command', () => {
})
})

test('should create a new edge function directory when none is found', async () => {
await withSiteBuilder('site-with-no-functions-dir', async (builder) => {
test('should create a new edge function directory when none is found', async (t) => {
await withSiteBuilder(t, async (builder) => {
await builder.buildAsync()
await withMockApi(routes, async ({ apiUrl }) => {
const childProcess = execa(cliPath, ['functions:create'], getCLIOptions({ apiUrl, builder }))
Expand Down Expand Up @@ -107,8 +107,8 @@ describe.concurrent('functions:create command', () => {
})
})

test('should use specified edge function directory when found', async () => {
await withSiteBuilder('site-with-custom-edge-functions-dir', async (builder) => {
test('should use specified edge function directory when found', async (t) => {
await withSiteBuilder(t, async (builder) => {
builder.withNetlifyToml({ config: { build: { edge_functions: 'somethingEdgy' } } })
await builder.buildAsync()
await withMockApi(routes, async ({ apiUrl }) => {
Expand Down Expand Up @@ -143,8 +143,8 @@ describe.concurrent('functions:create command', () => {
})
})

test('should not create a new function directory when one is found', async () => {
await withSiteBuilder('site-with-functions-dir', async (builder) => {
test('should not create a new function directory when one is found', async (t) => {
await withSiteBuilder(t, async (builder) => {
builder.withNetlifyToml({ config: { build: { functions: 'functions' } } })

await builder.buildAsync()
Expand Down Expand Up @@ -180,9 +180,9 @@ describe.concurrent('functions:create command', () => {
})
})

test('should only show function templates for the language specified via the --language flag, if one is present', async () => {
test('should only show function templates for the language specified via the --language flag, if one is present', async (t) => {
const createWithLanguageTemplate = async (language, outputPath) =>
await withSiteBuilder('site-with-no-functions-dir', async (builder) => {
await withSiteBuilder(t, async (builder) => {
await builder.buildAsync()

const createFunctionQuestions = [
Expand Down Expand Up @@ -223,8 +223,8 @@ describe.concurrent('functions:create command', () => {
await createWithLanguageTemplate('typescript', 'hello-world/hello-world.ts')
})

test('throws an error when the --language flag contains an unsupported value', async () => {
await withSiteBuilder('site-with-no-functions-dir', async (builder) => {
test('throws an error when the --language flag contains an unsupported value', async (t) => {
await withSiteBuilder(t, async (builder) => {
await builder.buildAsync()

const createFunctionQuestions = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const withFunctionsServer = async ({ args = [], builder, port = DEFAULT_PORT },

describe.concurrent('functions:serve command', () => {
test('should serve functions on default port', async (t) => {
await withSiteBuilder('site-with-ping-function', async (builder) => {
await withSiteBuilder(t, async (builder) => {
await builder
.withNetlifyToml({ config: { functions: { directory: 'functions' } } })
.withFunction({
Expand All @@ -57,7 +57,7 @@ describe.concurrent('functions:serve command', () => {
})

test('should serve functions on custom port', async (t) => {
await withSiteBuilder('site-with-ping-function', async (builder) => {
await withSiteBuilder(t, async (builder) => {
await builder
.withNetlifyToml({ config: { functions: { directory: 'functions' } } })
.withFunction({
Expand All @@ -78,7 +78,7 @@ describe.concurrent('functions:serve command', () => {
})

test('should use settings from netlify.toml dev', async (t) => {
await withSiteBuilder('site-with-ping-function', async (builder) => {
await withSiteBuilder(t, async (builder) => {
const port = await getPort()
await builder
.withNetlifyToml({
Expand All @@ -102,7 +102,7 @@ describe.concurrent('functions:serve command', () => {
})

test('should inject env variables', async (t) => {
await withSiteBuilder('site-with-env-function', async (builder) => {
await withSiteBuilder(t, async (builder) => {
await builder
.withNetlifyToml({
config: {
Expand All @@ -129,7 +129,7 @@ describe.concurrent('functions:serve command', () => {
})

test('should handle content-types with charset', async (t) => {
await withSiteBuilder('site-with-env-function', async (builder) => {
await withSiteBuilder(t, async (builder) => {
await builder
.withNetlifyToml({
config: { functions: { directory: 'functions' } },
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/commands/integration/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe(`integration:deploy`, () => {
beforeEach(() => {
vi.resetAllMocks()
})
test('deploys an integration', async () => {
test('deploys an integration', async (t) => {
vi.mock(`../../../../src/commands/deploy/deploy.js`, () => ({
deploy: vi.fn(() => console.log(`yay it was mocked!`)),
}))
Expand Down Expand Up @@ -63,7 +63,7 @@ describe(`integration:deploy`, () => {
},
]

await withSiteBuilder('my-integration', async (builder) => {
await withSiteBuilder(t, async (builder) => {
builder.withContentFiles([
{
path: 'integration.yaml',
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/serve/functions-go.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe.concurrent('serve/functions-go', () => {
})
`)

await withSiteBuilder('go-function-update', async (builder) => {
await withSiteBuilder(t, async (builder) => {
try {
await builder
.withNetlifyToml({
Expand Down Expand Up @@ -138,7 +138,7 @@ describe.concurrent('serve/functions-go', () => {
})
`)

await withSiteBuilder('go-scheduled-function', async (builder) => {
await withSiteBuilder(t, async (builder) => {
try {
await builder
.withNetlifyToml({
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/serve/functions-rust.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { withSiteBuilder } from '../utils/site-builder.ts'
const WAIT_WRITE = 1000

test('Updates a Rust function when a file is modified', async (t) => {
await withSiteBuilder('rust-function-update', async (builder) => {
await withSiteBuilder(t, async (builder) => {
const originalBody = 'Netlify likes Rust'
const updatedBody = 'Netlify *loves* Rust'

Expand Down
Loading
Loading