Skip to content

Commit bec9b7b

Browse files
committed
add a small integration test for the new variable setting feature
1 parent 3a88040 commit bec9b7b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

tests/index.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ async fn test_404() {
4343
}
4444
}
4545

46+
#[actix_web::test]
47+
async fn test_set_variable() {
48+
let resp = req_path("/tests/test_set_variable.sql").await.unwrap();
49+
let body = test::read_body(resp).await;
50+
assert!(body.starts_with(b"<!DOCTYPE html>"));
51+
// the body should contain the strint "It works!" and should not contain the string "error"
52+
let body = String::from_utf8(body.to_vec()).unwrap();
53+
assert!(body.contains("Hello John Doe !"), "{body}");
54+
assert!(body.contains("How are you John Doe ?"), "{body}");
55+
assert!(!body.contains("error"));
56+
}
57+
4658
async fn req_path(path: &str) -> Result<actix_web::dev::ServiceResponse, actix_web::Error> {
4759
init_log();
4860
let config = test_config();

tests/test_set_variable.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
set $person = 'John' || ' ' || 'Doe';
2+
select 'text' as component, 'Hello ' || $person || ' !' as contents;
3+
select 'text' as component, 'How are you ' || $person || ' ?' as contents;

0 commit comments

Comments
 (0)