Skip to content

Commit

Permalink
Adjust e2e tests to use Hyperdrive resource
Browse files Browse the repository at this point in the history
  • Loading branch information
mtlemilio committed Jan 15, 2025
1 parent 44c0acb commit ff5ca08
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
9 changes: 1 addition & 8 deletions packages/wrangler/e2e/dev-with-resources.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,6 @@ describe.sequential.each(RUNTIMES)("Bindings: $flags", ({ runtime, flags }) => {
async fetch(request, env) {
if (request.url.includes("connect")) {
const conn = env.HYPERDRIVE.connect();
await conn.writable.getWriter().write(new TextEncoder().encode("test string"));
}
return new Response(env.HYPERDRIVE?.connectionString ?? "no")
}
Expand All @@ -608,13 +607,7 @@ describe.sequential.each(RUNTIMES)("Bindings: $flags", ({ runtime, flags }) => {

const worker = helper.runLongLived(`wrangler dev ${flags}`);
const { url } = await worker.waitForReady();
const text = await fetchText(url);

const hyperdrive = new URL(text);
expect(hyperdrive.pathname).toBe("/some_db");
expect(hyperdrive.username).toBe("user");
expect(hyperdrive.password).toBe("!pass");
expect(hyperdrive.host).not.toBe("localhost");
await fetch(`${url}/connect`);
});

it.skipIf(!isLocal).fails("exposes Pipelines bindings", async () => {
Expand Down
13 changes: 4 additions & 9 deletions packages/wrangler/e2e/dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,8 @@ describe("hyperdrive dev tests", () => {

it("does not require local connection string when running `wrangler dev --remote`", async () => {
const helper = new WranglerE2ETestHelper();
const { id } = await helper.hyperdrive(false);

await helper.seed({
"wrangler.toml": dedent`
name = "${workerName}"
Expand All @@ -663,14 +665,13 @@ describe("hyperdrive dev tests", () => {
[[hyperdrive]]
binding = "HYPERDRIVE"
id = "hyperdrive_id"
id = "${id}"
`,
"src/index.ts": dedent`
export default {
async fetch(request, env) {
if (request.url.includes("connect")) {
const conn = env.HYPERDRIVE.connect();
await conn.writable.getWriter().write(new TextEncoder().encode("test string"));
}
return new Response(env.HYPERDRIVE?.connectionString ?? "no")
}
Expand All @@ -687,13 +688,7 @@ describe("hyperdrive dev tests", () => {
const worker = helper.runLongLived("wrangler dev --remote");

const { url } = await worker.waitForReady();
const text = await fetchText(url);

const hyperdrive = new URL(text);
expect(hyperdrive.pathname).toBe("/some_db");
expect(hyperdrive.username).toBe("user");
expect(hyperdrive.password).toBe("!pass");
expect(hyperdrive.host).not.toBe("localhost");
await fetch(`${url}/connect`);
});

afterEach(() => {
Expand Down

0 comments on commit ff5ca08

Please sign in to comment.