Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
test: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
khendrikse committed Jan 11, 2023
1 parent f210cdb commit 763f07d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/zip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ export const zipFunctions = async function (
const logger = getLogger(systemLog, debug)
const cache = new RuntimeCache()
const featureFlags = getFlags(inputFeatureFlags)
const srcFolders = resolveFunctionsDirectories(
[...relativeSrcFolders, internalFunctionsFolder].filter(Boolean) as string[],
)
const functionsDirectories = [
...(Array.isArray(relativeSrcFolders) ? relativeSrcFolders : [relativeSrcFolders]),
internalFunctionsFolder,
].filter(Boolean) as string[]
const srcFolders = resolveFunctionsDirectories(functionsDirectories)
const internalFunctionsPath = internalFunctionsFolder && resolve(internalFunctionsFolder)

const [paths] = await Promise.all([listFunctionsDirectories(srcFolders), fs.mkdir(destFolder, { recursive: true })])
Expand Down
17 changes: 11 additions & 6 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import unixify from 'unixify'
import { afterAll, afterEach, describe, expect, test, vi } from 'vitest'

import type { Config } from '../src/config.js'
import { FUNCTIONS_INTERNAL_DIR } from '../src/runtimes/constants.js'
import { ESBUILD_LOG_LIMIT } from '../src/runtimes/node/bundlers/esbuild/bundler.js'
import { NodeBundlerType } from '../src/runtimes/node/bundlers/types.js'
import { detectEsModule } from '../src/runtimes/node/utils/detect_es_module.js'
Expand Down Expand Up @@ -75,10 +74,14 @@ describe('zip-it-and-ship-it', () => {
'Zips Node.js function files from an internal-functions dir with a configured displayName',
[...allBundleConfigs, 'bundler_none'],
async (options) => {
const fixtureName = join('node-internal', FUNCTIONS_INTERNAL_DIR)
const { files } = await zipNode(fixtureName, {
const fixtureName = join('node-internal', '.netlify/internal-functions')
const { files } = await zipFixture(fixtureName, {
length: 2,
opts: { ...options, config: { 'function-1': { displayName: 'Function One' } } },
opts: {
internalFunctionsFolder: join(FIXTURES_DIR, fixtureName),
...options,
config: { 'function-1': { displayName: 'Function One' } },
},
})
expect(files).toHaveLength(2)
expect(files[0].isInternalFunction).toBeTruthy()
Expand Down Expand Up @@ -1769,10 +1772,11 @@ describe('zip-it-and-ship-it', () => {
return {} as any
})

const fixtureName = join('go-internal', FUNCTIONS_INTERNAL_DIR)
const fixtureName = join('go-internal', '.netlify/internal-functions')
const { files } = await zipFixture(fixtureName, {
length: 2,
opts: {
internalFunctionsFolder: join(FIXTURES_DIR, fixtureName),
config: {
'go-func-1': {
displayName: 'Go Function One',
Expand Down Expand Up @@ -1962,10 +1966,11 @@ describe('zip-it-and-ship-it', () => {
}
})

const fixtureName = join('rust-internal', FUNCTIONS_INTERNAL_DIR)
const fixtureName = join('rust-internal', '.netlify/internal-functions')
const { files } = await zipFixture(fixtureName, {
length: 2,
opts: {
internalFunctionsFolder: join(FIXTURES_DIR, fixtureName),
config: {
'rust-func-1': {
displayName: 'Rust Function Two',
Expand Down

0 comments on commit 763f07d

Please sign in to comment.