Skip to content

Commit 17d9825

Browse files
committed
test: cleanup semver checks surrounding node v16
1 parent 9af51da commit 17d9825

File tree

4 files changed

+168
-186
lines changed

4 files changed

+168
-186
lines changed

packages/build/tests/blobs_upload/tests.js

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -210,35 +210,32 @@ test.serial('Blobs upload step cancels deploy if blob metadata is malformed', as
210210
t.is(severityCode, 4)
211211
})
212212

213-
// the monorepo works with pnpm which is not available on node 14 tests
214-
if (semver.gte(nodeVersion, '16.9.0')) {
215-
test.serial('monorepo > blobs upload, uploads files to deploy store', async (t) => {
216-
const fixture = await new Fixture('./fixtures/monorepo').withCopyRoot({ git: false })
217-
const { success } = await fixture
218-
.withFlags({ deployId: 'abc123', siteId: 'test', token: TOKEN, offline: true, packagePath: 'apps/app-1' })
219-
.runBuildProgrammatic()
213+
test.serial('monorepo > blobs upload, uploads files to deploy store', async (t) => {
214+
const fixture = await new Fixture('./fixtures/monorepo').withCopyRoot({ git: false })
215+
const { success } = await fixture
216+
.withFlags({ deployId: 'abc123', siteId: 'test', token: TOKEN, offline: true, packagePath: 'apps/app-1' })
217+
.runBuildProgrammatic()
220218

221-
t.true(success)
222-
t.is(t.context.blobRequests.set.length, 6)
219+
t.true(success)
220+
t.is(t.context.blobRequests.set.length, 6)
223221

224-
const storeOpts = { deployID: 'abc123', siteID: 'test', token: TOKEN }
225-
if (semver.lt(nodeVersion, '18.0.0')) {
226-
const nodeFetch = await import('node-fetch')
227-
storeOpts.fetch = nodeFetch.default
228-
}
222+
const storeOpts = { deployID: 'abc123', siteID: 'test', token: TOKEN }
223+
if (semver.lt(nodeVersion, '18.0.0')) {
224+
const nodeFetch = await import('node-fetch')
225+
storeOpts.fetch = nodeFetch.default
226+
}
229227

230-
const store = getDeployStore(storeOpts)
228+
const store = getDeployStore(storeOpts)
231229

232-
const blob1 = await store.getWithMetadata('something.txt')
233-
t.is(blob1.data, 'some value')
234-
t.deepEqual(blob1.metadata, {})
230+
const blob1 = await store.getWithMetadata('something.txt')
231+
t.is(blob1.data, 'some value')
232+
t.deepEqual(blob1.metadata, {})
235233

236-
const blob2 = await store.getWithMetadata('with-metadata.txt')
237-
t.is(blob2.data, 'another value')
238-
t.deepEqual(blob2.metadata, { meta: 'data', number: 1234 })
234+
const blob2 = await store.getWithMetadata('with-metadata.txt')
235+
t.is(blob2.data, 'another value')
236+
t.deepEqual(blob2.metadata, { meta: 'data', number: 1234 })
239237

240-
const blob3 = await store.getWithMetadata('nested/file.txt')
241-
t.is(blob3.data, 'file value')
242-
t.deepEqual(blob3.metadata, { some: 'metadata' })
243-
})
244-
}
238+
const blob3 = await store.getWithMetadata('nested/file.txt')
239+
t.is(blob3.data, 'file value')
240+
t.deepEqual(blob3.metadata, { some: 'metadata' })
241+
})

packages/build/tests/edge_functions/tests.js

Lines changed: 68 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { promises as fs } from 'fs'
22
import { join } from 'path'
3-
import { platform, version as nodeVersion } from 'process'
3+
import { platform } from 'process'
44
import { fileURLToPath } from 'url'
55

66
import { Fixture, normalizeOutput } from '@netlify/testing'
77
import test from 'ava'
88
import { pathExists } from 'path-exists'
9-
import semver from 'semver'
109
import tmp from 'tmp-promise'
1110

1211
import { importJsonFile } from '../../lib/utils/json.js'
@@ -215,10 +214,31 @@ test.serial('cleans up the edge functions dist directory before bundling', async
215214
t.false(await pathExists(oldBundlePath))
216215
})
217216

218-
// Targeting Node 16.7.0+ because these fixtures rely on `fs.cp()`.
219-
if (semver.gte(nodeVersion, '16.7.0')) {
220-
test.serial('builds edge functions generated with the Frameworks API', async (t) => {
221-
const output = await new Fixture('./fixtures/functions_user_framework')
217+
test.serial('builds edge functions generated with the Frameworks API', async (t) => {
218+
const output = await new Fixture('./fixtures/functions_user_framework')
219+
.withFlags({
220+
debug: false,
221+
mode: 'buildbot',
222+
})
223+
.runWithBuild()
224+
225+
t.snapshot(normalizeOutput(output))
226+
227+
const { routes } = await assertManifest(t, 'functions_user_framework')
228+
229+
t.is(routes.length, 1)
230+
t.deepEqual(routes[0], {
231+
function: 'function-2',
232+
pattern: '^/framework(?:/(.*))/?$',
233+
excluded_patterns: ['^/framework/skip_(.*)/?$'],
234+
path: '/framework/*',
235+
})
236+
})
237+
238+
test.serial(
239+
'builds both edge functions generated with the Frameworks API and the ones in the internal directory',
240+
async (t) => {
241+
const output = await new Fixture('./fixtures/functions_user_internal_framework')
222242
.withFlags({
223243
debug: false,
224244
mode: 'buildbot',
@@ -227,69 +247,45 @@ if (semver.gte(nodeVersion, '16.7.0')) {
227247

228248
t.snapshot(normalizeOutput(output))
229249

230-
const { routes } = await assertManifest(t, 'functions_user_framework')
231-
232-
t.is(routes.length, 1)
233-
t.deepEqual(routes[0], {
234-
function: 'function-2',
235-
pattern: '^/framework(?:/(.*))/?$',
236-
excluded_patterns: ['^/framework/skip_(.*)/?$'],
237-
path: '/framework/*',
238-
})
239-
})
240-
241-
test.serial(
242-
'builds both edge functions generated with the Frameworks API and the ones in the internal directory',
243-
async (t) => {
244-
const output = await new Fixture('./fixtures/functions_user_internal_framework')
245-
.withFlags({
246-
debug: false,
247-
mode: 'buildbot',
248-
})
249-
.runWithBuild()
250-
251-
t.snapshot(normalizeOutput(output))
252-
253-
const { routes } = await assertManifest(t, 'functions_user_internal_framework')
254-
255-
t.deepEqual(routes, [
256-
{
257-
function: 'frameworks-internal-conflict',
258-
pattern: '^/frameworks-internal-conflict/frameworks/?$',
259-
excluded_patterns: [],
260-
path: '/frameworks-internal-conflict/frameworks',
261-
},
262-
{
263-
function: 'function-3',
264-
pattern: '^/internal(?:/(.*))/?$',
265-
excluded_patterns: ['^/internal/skip_(.*)/?$'],
266-
path: '/internal/*',
267-
},
268-
{
269-
function: 'frameworks-user-conflict',
270-
pattern: '^/frameworks-user-conflict/frameworks/?$',
271-
excluded_patterns: [],
272-
path: '/frameworks-user-conflict/frameworks',
273-
},
274-
{
275-
function: 'function-2',
276-
pattern: '^/framework(?:/(.*))/?$',
277-
excluded_patterns: ['^/framework/skip_(.*)/?$'],
278-
path: '/framework/*',
279-
},
280-
{
281-
function: 'frameworks-user-conflict',
282-
pattern: '^/frameworks-user-conflict/user/?$',
283-
excluded_patterns: [],
284-
path: '/frameworks-user-conflict/user',
285-
},
286-
{
287-
function: 'function-1',
288-
pattern: '^/user/?$',
289-
excluded_patterns: [],
290-
path: '/user',
291-
},
292-
])
293-
},
294-
)
295-
}
250+
const { routes } = await assertManifest(t, 'functions_user_internal_framework')
251+
252+
t.deepEqual(routes, [
253+
{
254+
function: 'frameworks-internal-conflict',
255+
pattern: '^/frameworks-internal-conflict/frameworks/?$',
256+
excluded_patterns: [],
257+
path: '/frameworks-internal-conflict/frameworks',
258+
},
259+
{
260+
function: 'function-3',
261+
pattern: '^/internal(?:/(.*))/?$',
262+
excluded_patterns: ['^/internal/skip_(.*)/?$'],
263+
path: '/internal/*',
264+
},
265+
{
266+
function: 'frameworks-user-conflict',
267+
pattern: '^/frameworks-user-conflict/frameworks/?$',
268+
excluded_patterns: [],
269+
path: '/frameworks-user-conflict/frameworks',
270+
},
271+
{
272+
function: 'function-2',
273+
pattern: '^/framework(?:/(.*))/?$',
274+
excluded_patterns: ['^/framework/skip_(.*)/?$'],
275+
path: '/framework/*',
276+
},
277+
{
278+
function: 'frameworks-user-conflict',
279+
pattern: '^/frameworks-user-conflict/user/?$',
280+
excluded_patterns: [],
281+
path: '/frameworks-user-conflict/user',
282+
},
283+
{
284+
function: 'function-1',
285+
pattern: '^/user/?$',
286+
excluded_patterns: [],
287+
path: '/user',
288+
},
289+
])
290+
},
291+
)

packages/build/tests/frameworks_api/tests.js

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { promises as fs } from 'fs'
22
import { dirname, resolve } from 'path'
3-
import { platform, version as nodeVersion } from 'process'
3+
import { platform } from 'process'
44

55
import { Fixture } from '@netlify/testing'
66
import test from 'ava'
7-
import semver from 'semver'
87
import tmp from 'tmp-promise'
98

109
test('Does not mutate read-only properties', async (t) => {
@@ -95,23 +94,20 @@ test('Loads configuration data that has been generated by the build command usin
9594
}
9695
})
9796

98-
// pnpm is not available in Node 14.
99-
if (semver.gte(nodeVersion, '16.9.0')) {
100-
test('In a monorepo setup, loads package-specific configuration data', async (t) => {
101-
const fixture = await new Fixture('./fixtures/monorepo').withCopyRoot({ git: false })
102-
const { success, netlifyConfig } = await fixture
103-
.withFlags({
104-
cwd: fixture.repositoryRoot,
105-
packagePath: 'apps/app-1',
106-
})
107-
.runWithBuildAndIntrospect()
108-
109-
t.true(success)
110-
t.deepEqual(netlifyConfig.images, {
111-
remote_images: ['domain1.netlify', 'domain2.netlify'],
97+
test('In a monorepo setup, loads package-specific configuration data', async (t) => {
98+
const fixture = await new Fixture('./fixtures/monorepo').withCopyRoot({ git: false })
99+
const { success, netlifyConfig } = await fixture
100+
.withFlags({
101+
cwd: fixture.repositoryRoot,
102+
packagePath: 'apps/app-1',
112103
})
104+
.runWithBuildAndIntrospect()
105+
106+
t.true(success)
107+
t.deepEqual(netlifyConfig.images, {
108+
remote_images: ['domain1.netlify', 'domain2.netlify'],
113109
})
114-
}
110+
})
115111

116112
test('Configuration data is exposed to build plugins in the `onBuild` event', async (t) => {
117113
const { netlifyConfig, success } = await new Fixture('./fixtures/with_build_plugin').runWithBuildAndIntrospect()

0 commit comments

Comments
 (0)