Skip to content

Commit d47e476

Browse files
committed
fix some tests
1 parent 343bddc commit d47e476

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

worker-sandbox/src/d1.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ pub async fn exec(req: http::Request<Body>, env: &Env) -> Result<http::Response<
8383

8484
pub async fn dump(env: &Env) -> Result<http::Response<Body>> {
8585
let db = env.d1("DB")?;
86+
console_log!("HERE");
8687
let bytes = db.dump().await?;
88+
console_log!("TERE");
8789
Ok(http::Response::new(bytes.into()))
8890
}
8991

@@ -97,7 +99,7 @@ pub async fn error(env: &Env) -> Result<http::Response<Body>> {
9799
if let Error::D1(error) = error {
98100
assert_eq!(
99101
error.cause(),
100-
"Error in line 1: THIS IS NOT VALID SQL: SqliteError: near \"THIS\": syntax error"
102+
"Error in line 1: THIS IS NOT VALID SQL: near \"THIS\": syntax error at offset 0"
101103
)
102104
} else {
103105
panic!("expected D1 error");

worker-sandbox/src/lib.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,12 @@ pub async fn main(
330330
// https://developers.cloudflare.com/workers/platform/compatibility-dates#durable-object-stubfetch-requires-a-full-url
331331
stub.fetch_with_str("https://fake-host/alarm").await
332332
})
333+
.get("/durable/put-raw", |req, ctx| async move {
334+
let namespace = ctx.data.durable_object("PUT_RAW_TEST_OBJECT")?;
335+
let id = namespace.unique_id()?;
336+
let stub = id.get_stub()?;
337+
stub.fetch_with_request(req).await
338+
})
333339
.get("/durable/:id", |_req, ctx| async move {
334340
let namespace = ctx.data.durable_object("COUNTER")?;
335341
let stub = namespace.id_from_name("A")?.get_stub()?;
@@ -469,7 +475,7 @@ pub async fn main(
469475
let mut init = RequestInit::new();
470476
init.method = Method::POST;
471477

472-
let req = http::Request::post("https://httpbin.org/post").body(()).unwrap();
478+
let req = http::Request::post("http://httpbin.org/post").body(()).unwrap();
473479
fetch_with_init(req, &init).await
474480
})
475481
.get("/cancelled-fetch", |_, _| async move {

worker-sandbox/tests/mf.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Miniflare, Response } from "miniflare";
2-
import { MockAgent } from "undici";
2+
import { MockAgent, MockClient } from "undici";
33

44
const mockAgent = new MockAgent();
55

@@ -8,6 +8,12 @@ mockAgent
88
.intercept({ path: "/" })
99
.reply(200, "cloudflare!");
1010

11+
let httpbinClient = new MockClient("https://httpbin.org", { agent: mockAgent });
12+
httpbinClient.intercept({ path: "/post", method: 'POST' })
13+
.reply(200, {
14+
url: "http://httpbin.org/post"
15+
});
16+
1117
mockAgent
1218
.get("https://miniflare.mocks")
1319
.intercept({ path: "/delay" })

worker-sandbox/tests/subrequest.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe("subrequest", () => {
2222
"https://fake.host/request-init-fetch-post"
2323
);
2424
expect(await resp.json()).toMatchObject({
25-
url: "https://httpbin.org/post",
25+
url: "http://httpbin.org/post",
2626
});
2727
});
2828
});

worker-sandbox/wrangler.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ bindings = [
2828
[[d1_databases]]
2929
binding = 'DB'
3030
database_name = 'my_db'
31-
database_id = 'test'
32-
preview_database_id = 'preview-test'
31+
database_id = '8b1e9b5a-788c-4aed-adcf-409b61dd5da8'
32+
preview_database_id = '8b1e9b5a-788c-4aed-adcf-409b61dd5da8'
3333

3434
[[queues.consumers]]
3535
queue = "my_queue"

0 commit comments

Comments
 (0)