Skip to content

Commit

Permalink
remove newlines from tests for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
lovasoa committed Apr 21, 2024
1 parent 066c80a commit 5c6e992
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
27 changes: 15 additions & 12 deletions tests/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,21 @@ async fn test_concurrent_requests() {

fn start_echo_server() -> ServerHandle {
async fn echo_server(mut r: ServiceRequest) -> actix_web::Result<ServiceResponse> {
let method = r.method();
let path = r.uri();
let mut headers_vec = r
.headers()
.into_iter()
.map(|(k, v)| format!("{k}: {}", String::from_utf8_lossy(v.as_bytes())))
.collect::<Vec<_>>();
headers_vec.sort();
let headers = headers_vec.join("\n");
let mut resp_bytes = format!("{method} {path}\n{headers}\n\n").into_bytes();
resp_bytes.extend(r.extract::<actix_web::web::Bytes>().await?);
let resp = HttpResponse::Ok().body(resp_bytes);
use std::io::Write;
let mut f = Vec::new();
write!(f, "{} {}", r.method(), r.uri()).unwrap();
let mut sorted_headers = r.headers().into_iter().collect::<Vec<_>>();
sorted_headers.sort_by_key(|(k, _)| k.as_str());
for (k, v) in sorted_headers {
if k.as_str().eq_ignore_ascii_case("date") {
continue;
}
write!(f, "|{k}: ").unwrap();
f.extend_from_slice(v.as_bytes());
}
f.push(b'|');
f.extend_from_slice(&r.extract::<actix_web::web::Bytes>().await?);
let resp = HttpResponse::Ok().body(f);
Ok(r.into_response(resp))
}
let server = actix_web::HttpServer::new(move || {
Expand Down
17 changes: 5 additions & 12 deletions tests/sql_test_files/it_works_fetch_post.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@ set res = sqlpage.fetch('{
"headers": {"x-custom": "1"},
"body": {"hello": "world"}
}');
set expected_like = 'POST /post
accept-encoding: br, gzip, deflate, zstd
content-length: 18
content-type: application/json
date: %
host: localhost:62802
x-custom: 1
{"hello": "world"}';
set expected = 'POST /post|accept-encoding: br, gzip, deflate, zstd|content-length: 18|content-type: application/json|host: localhost:62802|x-custom: 1|{"hello": "world"}';
select 'text' as component,
case
when $res LIKE $expected_like then 'It works !'
case $res
when $expected then 'It works !'
else 'It failed ! Expected:
' || $expected_like || 'Got:
' || $expected || '
Got:
' || $res
end as contents;

0 comments on commit 5c6e992

Please sign in to comment.