Move exec SQL test to dedicated Rust test
This commit is contained in:
@@ -0,0 +1 @@
|
||||
select sqlpage.exec($exec_program, $exec_arg1, $exec_arg2, 'It', $thisisnull, 'works', '!') as actual;
|
||||
@@ -0,0 +1,29 @@
|
||||
use actix_web::{http::header, test::TestRequest};
|
||||
use sqlpage::webserver::http::main_handler;
|
||||
|
||||
#[actix_web::test]
|
||||
async fn test_exec() {
|
||||
let app_data = crate::common::make_app_data().await;
|
||||
let req = TestRequest::get()
|
||||
.uri(exec_test_uri())
|
||||
.app_data(app_data)
|
||||
.insert_header(header::Accept::json())
|
||||
.to_srv_request();
|
||||
|
||||
let resp = main_handler(req).await.unwrap();
|
||||
let body = actix_web::test::read_body(resp).await;
|
||||
let rows: Vec<serde_json::Value> = serde_json::from_slice(&body).unwrap();
|
||||
let actual = rows[0]["actual"].as_str().unwrap();
|
||||
|
||||
assert!(actual.contains("It works !"), "actual: {actual:?}");
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn exec_test_uri() -> &'static str {
|
||||
"/tests/exec/exec.sql?exec_program=cmd.exe&exec_arg1=/C&exec_arg2=echo"
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn exec_test_uri() -> &'static str {
|
||||
"/tests/exec/exec.sql?exec_program=echo"
|
||||
}
|
||||
@@ -3,6 +3,7 @@ mod common;
|
||||
mod core;
|
||||
mod data_formats;
|
||||
mod errors;
|
||||
mod exec;
|
||||
mod oidc;
|
||||
mod requests;
|
||||
mod server_timing;
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
select 'It works !' as expected_contains,
|
||||
sqlpage.exec('echo', 'It', $thisisnull, 'works', '!') as actual;
|
||||
Reference in New Issue
Block a user