Skip to content

Commit 7baf677

Browse files
committed
fix tests on master
1 parent 17b1c5e commit 7baf677

File tree

4 files changed

+18
-34
lines changed

4 files changed

+18
-34
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ unstable = []
3232
__internal__bench = []
3333

3434
[dependencies]
35-
async-h1 = { version = "2.0.0", optional = true }
35+
async-h1 = { version = "2.0.1", optional = true }
3636
async-sse = "3.0.0"
3737
async-std = { version = "1.6.0", features = ["unstable"] }
3838
femme = "2.0.1"
@@ -47,9 +47,9 @@ serde_qs = "0.5.0"
4747
async-std = { version = "1.6.0", features = ["unstable", "attributes"] }
4848
juniper = "0.14.1"
4949
portpicker = "0.1.0"
50+
surf = { version = "2.0.0-alpha.3", default-features = false, features = ["h1-client"] }
5051
serde = { version = "1.0.102", features = ["derive"] }
5152
criterion = "0.3.1"
52-
surf = { version = "2.0.0-alpha.2", default-features = false, features = ["h1-client"] }
5353
tempdir = "0.3.7"
5454

5555
[[test]]

tests/chunked-encode-large.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,8 @@ async fn chunked_large() -> Result<(), http_types::Error> {
8888
.await
8989
.unwrap();
9090
assert_eq!(res.status(), 200);
91-
assert_eq!(
92-
// this is awkward and should be revisited when surf is on newer http-types
93-
res.header(&"transfer-encoding".parse().unwrap())
94-
.unwrap()
95-
.last()
96-
.unwrap()
97-
.as_str(),
98-
"chunked"
99-
);
100-
assert_eq!(res.header(&"content-length".parse().unwrap()), None);
91+
assert_eq!(res.header("transfer-encoding").unwrap(), "chunked");
92+
assert!(res.header("content-length").is_none());
10193
let string = res.body_string().await.unwrap();
10294
assert_eq!(string, TEXT.to_string());
10395
Ok(())

tests/chunked-encode-small.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,8 @@ async fn chunked_large() -> Result<(), http_types::Error> {
3838
.await
3939
.unwrap();
4040
assert_eq!(res.status(), 200);
41-
assert_eq!(
42-
// this is awkward and should be revisited when surf is on newer http-types
43-
res.header(&"transfer-encoding".parse().unwrap())
44-
.unwrap()
45-
.last()
46-
.unwrap()
47-
.as_str(),
48-
"chunked"
49-
);
50-
assert_eq!(res.header(&"content-length".parse().unwrap()), None);
41+
assert_eq!(res.header("transfer-encoding").unwrap(), "chunked");
42+
assert!(res.header("content-length").is_none());
5143
let string = res.body_string().await.unwrap();
5244
assert_eq!(string, TEXT.to_string());
5345
Ok(())

tests/wildcard.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ async fn wildcard() {
4141
Method::Get,
4242
Url::parse("http://localhost/add_one/3").unwrap(),
4343
);
44-
let res: http::Response = app.respond(req).await.unwrap();
44+
let mut res: http::Response = app.respond(req).await.unwrap();
4545
assert_eq!(res.status(), StatusCode::Ok);
4646
assert_eq!(&res.body_string().await.unwrap(), "4");
4747

4848
let req = http::Request::new(
4949
Method::Get,
5050
Url::parse("http://localhost/add_one/-7").unwrap(),
5151
);
52-
let res: http::Response = app.respond(req).await.unwrap();
52+
let mut res: http::Response = app.respond(req).await.unwrap();
5353
assert_eq!(res.status(), StatusCode::Ok);
5454
assert_eq!(&res.body_string().await.unwrap(), "-6");
5555
}
@@ -89,20 +89,20 @@ async fn wild_path() {
8989
Method::Get,
9090
Url::parse("http://localhost/echo/some_path").unwrap(),
9191
);
92-
let res: http::Response = app.respond(req).await.unwrap();
92+
let mut res: http::Response = app.respond(req).await.unwrap();
9393
assert_eq!(res.status(), StatusCode::Ok);
9494
assert_eq!(&res.body_string().await.unwrap(), "some_path");
9595

9696
let req = http::Request::new(
9797
Method::Get,
9898
Url::parse("http://localhost/echo/multi/segment/path").unwrap(),
9999
);
100-
let res: http::Response = app.respond(req).await.unwrap();
100+
let mut res: http::Response = app.respond(req).await.unwrap();
101101
assert_eq!(res.status(), StatusCode::Ok);
102102
assert_eq!(&res.body_string().await.unwrap(), "multi/segment/path");
103103

104104
let req = http::Request::new(Method::Get, Url::parse("http://localhost/echo/").unwrap());
105-
let res: http::Response = app.respond(req).await.unwrap();
105+
let mut res: http::Response = app.respond(req).await.unwrap();
106106
assert_eq!(res.status(), StatusCode::NotFound);
107107
assert_eq!(&res.body_string().await.unwrap(), "");
108108
}
@@ -116,15 +116,15 @@ async fn multi_wildcard() {
116116
Method::Get,
117117
Url::parse("http://localhost/add_two/1/2/").unwrap(),
118118
);
119-
let res: http::Response = app.respond(req).await.unwrap();
119+
let mut res: http::Response = app.respond(req).await.unwrap();
120120
assert_eq!(res.status(), StatusCode::Ok);
121121
assert_eq!(&res.body_string().await.unwrap(), "3");
122122

123123
let req = http::Request::new(
124124
Method::Get,
125125
Url::parse("http://localhost/add_two/-1/2/").unwrap(),
126126
);
127-
let res: http::Response = app.respond(req).await.unwrap();
127+
let mut res: http::Response = app.respond(req).await.unwrap();
128128
assert_eq!(res.status(), 200);
129129
assert_eq!(&res.body_string().await.unwrap(), "1");
130130

@@ -145,15 +145,15 @@ async fn wild_last_segment() {
145145
Method::Get,
146146
Url::parse("http://localhost/echo/one/two").unwrap(),
147147
);
148-
let res: http::Response = app.respond(req).await.unwrap();
148+
let mut res: http::Response = app.respond(req).await.unwrap();
149149
assert_eq!(res.status(), StatusCode::Ok);
150150
assert_eq!(&res.body_string().await.unwrap(), "one");
151151

152152
let req = http::Request::new(
153153
Method::Get,
154154
Url::parse("http://localhost/echo/one/two/three/four").unwrap(),
155155
);
156-
let res: http::Response = app.respond(req).await.unwrap();
156+
let mut res: http::Response = app.respond(req).await.unwrap();
157157
assert_eq!(res.status(), StatusCode::Ok);
158158
assert_eq!(&res.body_string().await.unwrap(), "one");
159159
}
@@ -207,15 +207,15 @@ async fn nameless_internal_wildcard() {
207207
Method::Get,
208208
Url::parse("http://localhost/echo/one/two").unwrap(),
209209
);
210-
let res: http::Response = app.respond(req).await.unwrap();
210+
let mut res: http::Response = app.respond(req).await.unwrap();
211211
assert_eq!(res.status(), StatusCode::Ok);
212212
assert_eq!(&res.body_string().await.unwrap(), "two");
213213

214214
let req = http::Request::new(
215215
Method::Get,
216216
Url::parse("http://localhost/echo/one/two").unwrap(),
217217
);
218-
let res: http::Response = app.respond(req).await.unwrap();
218+
let mut res: http::Response = app.respond(req).await.unwrap();
219219
assert_eq!(res.status(), StatusCode::Ok);
220220
assert_eq!(&res.body_string().await.unwrap(), "two");
221221
}
@@ -229,7 +229,7 @@ async fn nameless_internal_wildcard2() {
229229
Method::Get,
230230
Url::parse("http://localhost/echo/one/two").unwrap(),
231231
);
232-
let res: http::Response = app.respond(req).await.unwrap();
232+
let mut res: http::Response = app.respond(req).await.unwrap();
233233
assert_eq!(res.status(), StatusCode::Ok);
234234
assert_eq!(&res.body_string().await.unwrap(), "one");
235235
}

0 commit comments

Comments
 (0)