Skip to content

Commit 7f0ea28

Browse files
committed
fix test
1 parent c4d27c8 commit 7f0ea28

5 files changed

Lines changed: 19 additions & 7 deletions

File tree

Taskfile.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ tasks:
6767
test:examples:
6868
dir: ./examples
6969
cmds:
70-
- cargo test
70+
- chmod +x ./test.sh
71+
- ./test.sh
7172

7273
test:samples:
7374
dir: ./samples

examples/jwt/.env.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
JWT_SECRET=
1+
JWT_SECRET=your-jwt-secret-key

examples/jwt/src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ mod test {
6060
use ohkami::testing::*;
6161

6262
/// regression test for https://github.com/ohkami-rs/ohkami/issues/433
63+
///
64+
/// run with `OHKAMI_REQUEST_BUFSIZE=4096` or larger
6365
#[tokio::test]
6466
async fn test_large_jwt() {
6567
struct LargeJwtSub;
@@ -84,9 +86,6 @@ mod test {
8486
}
8587
}
8688

87-
// SAFETY: this crate contains only this single test
88-
unsafe {std::env::set_var("OHKAMI_REQUEST_BUFSIZE", (1 << 12).to_string())};
89-
9089
dotenvy::dotenv().ok();
9190

9291
let t = ohkami::<LargeJwtSub>().test();

examples/test.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
set -Cue
2+
3+
EXAMPLES=$(pwd)
4+
5+
cd $EXAMPLES/jwt && \
6+
cp .env.sample .env
7+
cd $EXAMPLES/jwt && \
8+
cargo test 2>&1 | grep 'Unexpected end of headers' \
9+
&& echo '---> expected error' \
10+
|| exit 1
11+
cd $EXAMPLES/jwt && \
12+
OHKAMI_REQUEST_BUFSIZE=4096 cargo test

ohkami/src/request/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl Request {
264264
let key_bytes = r.read_while(|b| b != &b':');
265265
r.consume(": ").ok_or_else(|| {
266266
crate::WARNING!("\
267-
[Request::read] Header key is not found. \
267+
[Request::read] Unexpected end of headers! \
268268
Maybe request buffer size is not enough. \
269269
Try to set `OHKAMI_REQUEST_BUFSIZE` to larger value \
270270
(default: 2048).\
@@ -275,7 +275,7 @@ impl Request {
275275
let value = CowSlice::Ref(Slice::from_bytes(r.read_while(|b| b != &b'\r')));
276276
r.consume("\r\n").ok_or_else(|| {
277277
crate::WARNING!("\
278-
[Request::read] Header value is not found. \
278+
[Request::read] Unexpected end of headers! \
279279
Maybe request buffer size is not enough. \
280280
Try to set `OHKAMI_REQUEST_BUFSIZE` to larger value \
281281
(default: 2048).\

0 commit comments

Comments
 (0)