File tree Expand file tree Collapse file tree 2 files changed +6
-18
lines changed Expand file tree Collapse file tree 2 files changed +6
-18
lines changed Original file line number Diff line number Diff line change 1
- use std:: { fs:: File , path:: PathBuf } ;
1
+ use async_std:: io:: Read ;
2
+ use async_std:: fs:: File ;
3
+ use async_std:: path:: PathBuf ;
2
4
3
5
#[ macro_export]
4
6
macro_rules! assert {
@@ -25,22 +27,9 @@ macro_rules! assert {
25
27
} ;
26
28
}
27
29
28
- pub fn read_fixture ( name : & str ) -> Vec < u8 > {
29
- use std:: io:: Read ;
30
-
30
+ pub fn read_fixture ( name : & str ) -> Arc < File > {
31
31
let directory: PathBuf = env ! ( "CARGO_MANIFEST_DIR" ) . into ( ) ;
32
32
let path: PathBuf = format ! ( "tests/fixtures/{}.txt" , name) . into ( ) ;
33
33
let mut file = File :: open ( directory. join ( path) ) . expect ( "Reading fixture file didn't work" ) ;
34
- let mut contents = Vec :: new ( ) ;
35
- file. read_to_end ( & mut contents)
36
- . expect ( "Couldn't read fixture files contents" ) ;
37
-
38
- let mut result = Vec :: < u8 > :: new ( ) ;
39
- for byte in contents {
40
- if byte == 0x0A {
41
- result. push ( 0x0D ) ;
42
- }
43
- result. push ( byte) ;
44
- }
45
- result
34
+ Arc :: new ( file)
46
35
}
Original file line number Diff line number Diff line change 1
1
mod common;
2
2
use async_h1:: server;
3
- use async_std:: io:: Cursor ;
4
3
use async_std:: task;
5
4
use common:: read_fixture;
6
5
use http_types:: { Response , StatusCode } ;
@@ -15,7 +14,7 @@ fn test_basic_request() {
15
14
assert ! (
16
15
actual,
17
16
expected,
18
- server:: accept( addr, Cursor :: new ( request) , & mut actual, |_req| {
17
+ server:: accept( addr, request, & mut actual, |_req| {
19
18
async {
20
19
let mut resp = Response :: new( StatusCode :: Ok ) ;
21
20
resp. set_body( "" ) ;
You can’t perform that action at this time.
0 commit comments