Skip to content

Commit 94f4038

Browse files
feat: implement and expose JavaScript classes for Fastly's Compute Core Cache feature set (#566)
Co-authored-by: Trevor Elliott <[email protected]>
1 parent 8b9e8a6 commit 94f4038

28 files changed

+7890
-198
lines changed

integration-tests/js-compute/fixtures/app/src/assertions.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
// Testing/Assertion functions //
22

3+
export async function sleep(milliseconds) {
4+
return new Promise(resolve => {
5+
setTimeout(resolve, milliseconds)
6+
})
7+
}
8+
39
// TODO: Implement ReadableStream getIterator() and [@@asyncIterator]() methods
410
export async function streamToString(stream) {
511
const decoder = new TextDecoder();
@@ -33,6 +39,7 @@ export function pass(message = '') {
3339
export function fail(message = '') {
3440
return new Response(message, { status: 500 })
3541
}
42+
3643
function prettyPrintSymbol (a) {
3744
if (typeof a === "symbol") {
3845
return String(a)

integration-tests/js-compute/fixtures/app/src/cache-core.js

Lines changed: 3202 additions & 0 deletions
Large diffs are not rendered by default.

integration-tests/js-compute/fixtures/app/src/cache-override.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ import { isRunningLocally, routes } from "./routes.js";
7676
{
7777
routes.set("/cache-override/fetch/mode-none", async () => {
7878
if (!isRunningLocally()) {
79-
const response = await fetch('https://httpbin.org/status/200', {
80-
backend: 'httpbin',
79+
const response = await fetch('https://http-me.glitch.me/now?status=200', {
80+
backend: 'httpme',
8181
cacheOverride: new CacheOverride('none')
8282
})
8383
let error = assert(response.headers.has('x-cache'), true, `CacheOveride('none'); response.headers.has('x-cache') === true`)
@@ -87,8 +87,8 @@ import { isRunningLocally, routes } from "./routes.js";
8787
});
8888
routes.set("/cache-override/fetch/mode-pass", async () => {
8989
if (!isRunningLocally()) {
90-
const response = await fetch('https://httpbin.org/status/200', {
91-
backend: 'httpbin',
90+
const response = await fetch('https://http-me.glitch.me/now?status=200', {
91+
backend: 'httpme',
9292
cacheOverride: new CacheOverride('pass')
9393
})
9494
let error = assert(response.headers.has('x-cache'), false, `CacheOveride('pass'); response.headers.has('x-cache') === false`)

integration-tests/js-compute/fixtures/app/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import "./btoa.js"
1010
import "./byob.js"
1111
import "./byte-repeater.js"
1212
import "./cache-override.js"
13+
import "./cache-core.js"
1314
import "./cache-simple.js"
1415
import "./client.js"
1516
import "./config-store.js"

integration-tests/js-compute/fixtures/app/src/routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ routes.set('/', () => {
1111
})
1212

1313
export function isRunningLocally() {
14-
return env('FASTLY_SERVICE_VERSION') === ''
14+
return env('FASTLY_SERVICE_VERSION') === '' || env('FASTLY_SERVICE_VERSION') === '0'
1515
}

0 commit comments

Comments
 (0)