feat: improve /scripts API (#390)

* feat: improve /scripts API

* chore: json_err macro

* chore: json_err macro and refactor code

* fix: test
This commit is contained in:
dennis zhuang
2022-11-04 14:09:07 +08:00
committed by GitHub
parent db2b577628
commit fc6d73b06b
3 changed files with 67 additions and 46 deletions

View File

@@ -5,7 +5,6 @@ use axum::http::StatusCode;
use axum::Router;
use axum_test_helper::TestClient;
use datatypes::prelude::ConcreteDataType;
use servers::http::handler::ScriptExecution;
use servers::http::HttpServer;
use servers::server::Server;
use test_util::TestGuard;
@@ -111,16 +110,14 @@ async fn test_scripts_api() {
let (app, _guard) = make_test_app("scripts_api").await;
let client = TestClient::new(app);
let res = client
.post("/v1/scripts")
.json(&ScriptExecution {
name: "test".to_string(),
script: r#"
.post("/v1/scripts?name=test")
.body(
r#"
@copr(sql='select number from numbers limit 10', args=['number'], returns=['n'])
def test(n):
return n + 1;
"#
.to_string(),
})
"#,
)
.send()
.await;
assert_eq!(res.status(), StatusCode::OK);