Skip to content
This repository was archived by the owner on Jul 14, 2025. It is now read-only.

Commit 9809f88

Browse files
committed
Add unit test for CRLF and WAT
Signed-off-by: Matt Butcher <[email protected]>
1 parent 65dd458 commit 9809f88

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ mod test {
7878
#[cfg(target_os = "windows")]
7979
const TEST2_MODULE_MAP_FILE: &str = "test2.toml";
8080
const TEST3_MODULE_MAP_FILE: &str = "test3.toml";
81+
const WAT_MODULE_MAP_FILE: &str = "wat.toml";
8182
const TEST_HEALTHZ_MODULE_MAP_FILE: &str = "test_healthz_override.toml";
8283
const TEST_DYNAMIC_ROUTES_MODULE_MAP_FILE: &str = "test_dynamic_routes.toml";
8384

@@ -341,6 +342,14 @@ mod test {
341342
}
342343
}
343344

345+
#[tokio::test]
346+
pub async fn can_serve_wat() {
347+
let route = "/";
348+
349+
let response = get_plain_text_response_from_module_map(WAT_MODULE_MAP_FILE, None, route).await;
350+
assert_eq!("Oh hi world\r\n", response);
351+
}
352+
344353
fn parse_ev_line(line: &str) -> Option<(String, String)> {
345354
line.find('=').and_then(|index| {
346355
let left = &line[..index];

testdata/module-maps/crlf.wat

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(module
2+
(import "wasi_snapshot_preview1" "fd_write" (func $fd_write (param i32 i32 i32 i32) (result i32)))
3+
(memory 1)
4+
(export "memory" (memory 0))
5+
6+
(data (i32.const 8) "content-type: text/plain\r\n\r\nOh hi world\r\n")
7+
8+
(func $main (export "_start")
9+
(i32.store (i32.const 0) (i32.const 8))
10+
(i32.store (i32.const 4) (i32.const 41))
11+
12+
(call $fd_write
13+
(i32.const 1)
14+
(i32.const 0)
15+
(i32.const 1)
16+
(i32.const 20)
17+
)
18+
drop
19+
)
20+
)

testdata/module-maps/wat.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[[module]]
2+
route = "/"
3+
module = "file:///${PROJECT_ROOT}/testdata/module-maps/crlf.wat"

0 commit comments

Comments
 (0)