diff options
author | 2023-08-11 19:39:44 +0530 | |
---|---|---|
committer | 2023-08-11 19:39:44 +0530 | |
commit | f974c95a27ccbf91adbc66f6f1433f4cf11be33e (patch) | |
tree | de4c8f89c7e6dcbec410f330c36f71cf1904ec4d /packages/integrations/netlify/test/functions | |
parent | 6a9fb2d95d309ba83c8337f68aed6f4e6f00be99 (diff) | |
download | astro-f974c95a27ccbf91adbc66f6f1433f4cf11be33e.tar.gz astro-f974c95a27ccbf91adbc66f6f1433f4cf11be33e.tar.zst astro-f974c95a27ccbf91adbc66f6f1433f4cf11be33e.zip |
Add Incremental Static Regeneration support for the Netlify's on-demand builders adapter (#7975)
* feat(netlify): expose builders ttl as a local
* add changeset
* docs(netlify): caching using on-demand builders
* reword readme section
* Update packages/integrations/netlify/package.json
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
* include builders-types.d.ts in the distribution
* document caveat regarding query params
* update changeset
* mutation -> function
* locals.netlify -> locals.runtime
* update types and changeset
* Apply suggestions from code review
Co-authored-by: Elian ☕️ <hello@elian.codes>
* Apply suggestions from code review
Co-authored-by: Elian ☕️ <hello@elian.codes>
---------
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
Co-authored-by: Elian ☕️ <hello@elian.codes>
Diffstat (limited to 'packages/integrations/netlify/test/functions')
-rw-r--r-- | packages/integrations/netlify/test/functions/builders.test.js | 37 | ||||
-rw-r--r-- | packages/integrations/netlify/test/functions/fixtures/builders/src/pages/index.astro | 11 |
2 files changed, 48 insertions, 0 deletions
diff --git a/packages/integrations/netlify/test/functions/builders.test.js b/packages/integrations/netlify/test/functions/builders.test.js new file mode 100644 index 000000000..5043b0ce0 --- /dev/null +++ b/packages/integrations/netlify/test/functions/builders.test.js @@ -0,0 +1,37 @@ +import { expect } from 'chai'; +import { loadFixture, testIntegration } from './test-utils.js'; +import netlifyAdapter from '../../dist/index.js'; + +describe('Builders', () => { + /** @type {import('../../../astro/test/test-utils').Fixture} */ + let fixture; + + before(async () => { + fixture = await loadFixture({ + root: new URL('./fixtures/builders/', import.meta.url).toString(), + output: 'server', + adapter: netlifyAdapter({ + dist: new URL('./fixtures/builders/dist/', import.meta.url), + builders: true + }), + site: `http://example.com`, + integrations: [testIntegration()], + }); + await fixture.build(); + }); + + it('A route can set builders ttl', async () => { + const entryURL = new URL( + './fixtures/builders/.netlify/functions-internal/entry.mjs', + import.meta.url + ); + const { handler } = await import(entryURL); + const resp = await handler({ + httpMethod: 'GET', + headers: {}, + rawUrl: 'http://example.com/', + isBase64Encoded: false, + }); + expect(resp.ttl).to.equal(45); + }); +}); diff --git a/packages/integrations/netlify/test/functions/fixtures/builders/src/pages/index.astro b/packages/integrations/netlify/test/functions/fixtures/builders/src/pages/index.astro new file mode 100644 index 000000000..ab8853785 --- /dev/null +++ b/packages/integrations/netlify/test/functions/fixtures/builders/src/pages/index.astro @@ -0,0 +1,11 @@ +--- +Astro.locals.runtime.setBuildersTtl(45) +--- +<html> + <head> + <title>Astro on Netlify</title> + </head> + <body> + <h1>{new Date(Date.now())}</h1> + </body> +</html> |