-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…38929) * test: add unit test for produced handler * actually failing test in windows * fix(gatsby-adapter-netlify): produce working function handlers on windows * fix(gatsby): functions compilation on windows * tmp: prepare cross-platform binaries for SSR/DSG * fix: lint * feat: add a way to configure functions executing platform/arch and add early check in DSG/SSR * refactor: move some utility functions around, cleanup standalone-regenrate, restore engine validation, add structured error and better error messages * chore: add jsdocs description for functionsPlatform and functionsArch optional config values passed by adapter * chore: make sure fs wrapper is first * fix: actually use values reported by adapter * test: try to setup windows adapters smoke test * test: typo * test: maybe cd into dirs? * test: no powershell fro smoke test * chore: single quote to double * chore: install node-gyp requirements * chore: install deps in win smoke * ? * newer node needed for ntl-cli * run ntl through yarn * Revert "run ntl through yarn" This reverts commit 8c55e40. * install ntl-cli in circleci pipeline * test: adjust lmdb regeneration test to changed internal-packages location * test: run windows deploy/smoke test after unit tests passed * chore: use path.posix to load engines in serve command * chore: use default value when destructuring instead of nullish coalescing later (cherry picked from commit c91ed28) Co-authored-by: Michal Piechowiak <misiek.piechowiak@gmail.com>
- Loading branch information
Showing
28 changed files
with
716 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import assert from "node:assert" | ||
|
||
{ | ||
// check index page (SSG) | ||
const response = await fetch(process.env.DEPLOY_URL) | ||
assert.equal(response.status, 200) | ||
|
||
const body = await response.text() | ||
assert.match(body, /<h1>Adapters<\/h1>/) | ||
assert.match(body, /<title[^>]*>Adapters E2E<\/title>/) | ||
} | ||
|
||
{ | ||
// check SSR page | ||
const response = await fetch( | ||
process.env.DEPLOY_URL + `/routes/ssr/remote-file/` | ||
) | ||
assert.equal(response.status, 200) | ||
|
||
const body = await response.text() | ||
// inline css for placeholder - this tests both LMDB and SHARP | ||
// (LMDB because of page query and sharp because page query will use sharp to generate placeholder values) | ||
assert.match(body, /background-color:rgb\(232,184,8\)/) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
46 changes: 46 additions & 0 deletions
46
packages/gatsby-adapter-netlify/src/__tests__/lambda-handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import fs from "fs-extra" | ||
import { prepareFunction } from "../lambda-handler" | ||
import { join, relative } from "path" | ||
import { slash } from "gatsby-core-utils/path" | ||
|
||
const writeFileSpy = jest | ||
.spyOn(fs, `writeFile`) | ||
.mockImplementation(async () => {}) | ||
const writeJsonSpy = jest | ||
.spyOn(fs, `writeJSON`) | ||
.mockImplementation(async () => {}) | ||
|
||
const fixturePath = join( | ||
relative(process.cwd(), __dirname), | ||
`fixtures`, | ||
`lambda-handler` | ||
) | ||
const pathToEntryPoint = join(fixturePath, `entry.js`) | ||
const requiredFile = join(fixturePath, `included.js`) | ||
|
||
test(`produced handler is correct`, async () => { | ||
await prepareFunction({ | ||
functionId: `test`, | ||
name: `test`, | ||
pathToEntryPoint, | ||
requiredFiles: [requiredFile], | ||
}) | ||
const handlerCode = writeFileSpy.mock.calls[0][1] | ||
// expect require in produced code (this is to mostly to make sure handlerCode is actual handler code) | ||
expect(handlerCode).toMatch(/require\(["'][^"']*["']\)/) | ||
// require paths should not have backward slashes (win paths) | ||
expect(handlerCode).not.toMatch(/require\(["'][^"']*\\[^"']*["']\)/) | ||
|
||
expect(writeJsonSpy).toBeCalledWith( | ||
expect.any(String), | ||
expect.objectContaining({ | ||
config: expect.objectContaining({ | ||
name: `test`, | ||
generator: expect.stringContaining(`gatsby-adapter-netlify`), | ||
includedFiles: [slash(requiredFile)], | ||
externalNodeModules: [`msgpackr-extract`], | ||
}), | ||
version: 1, | ||
}) | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.