parent
5248ae7ac4
commit
7735596bf0
11 changed files with 73 additions and 28 deletions
@ -1,8 +0,0 @@ |
|||||||
use u_agent::process_request; |
|
||||||
|
|
||||||
type TestResult<R = ()> = Result<R, Box<dyn std::error::Error>>; |
|
||||||
|
|
||||||
#[tokio::test] |
|
||||||
async fn test_first_connection() -> TestResult { |
|
||||||
Ok(()) |
|
||||||
} |
|
@ -1,2 +0,0 @@ |
|||||||
extern crate u_agent; |
|
||||||
mod behaviour; |
|
@ -0,0 +1,21 @@ |
|||||||
|
[package] |
||||||
|
name = "integration" |
||||||
|
version = "0.1.0" |
||||||
|
authors = ["plazmoid <kronos44@mail.ru>"] |
||||||
|
edition = "2018" |
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html |
||||||
|
|
||||||
|
[dependencies] |
||||||
|
tokio = { version = "1.2.0", features = ["macros", "rt-multi-thread", "process", "time"] } |
||||||
|
log = "^0.4" |
||||||
|
env_logger = "0.8.3" |
||||||
|
uuid = { version = "0.6.5", features = ["serde", "v4"] } |
||||||
|
reqwest = { version = "0.11", features = ["json"] } |
||||||
|
serde_json = "1.0" |
||||||
|
futures = "0.3.5" |
||||||
|
|
||||||
|
|
||||||
|
[[test]] |
||||||
|
name = "integration" |
||||||
|
path = "tests/tests.rs" |
@ -0,0 +1,3 @@ |
|||||||
|
fn main() { |
||||||
|
println!("Hello, world!"); |
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
use futures::Future; |
||||||
|
use reqwest::{Response, Result as RResult, Url}; |
||||||
|
use serde_json::{from_str, Value}; |
||||||
|
use uuid::Uuid; |
||||||
|
|
||||||
|
const SERVER: &str = "u_server"; |
||||||
|
const PORT: &str = "63714"; |
||||||
|
|
||||||
|
type TestResult<R = ()> = Result<R, Box<dyn std::error::Error>>; |
||||||
|
|
||||||
|
fn url<S: AsRef<str>>(url: S) -> Url { |
||||||
|
Url::parse(&format!("http://{}:{}/{}", SERVER, PORT, url.as_ref())).unwrap() |
||||||
|
} |
||||||
|
|
||||||
|
async fn unpack(req: impl Future<Output = RResult<Response>>) -> Value { |
||||||
|
let resp = req.await.unwrap().text().await.unwrap(); |
||||||
|
let resp: Value = from_str(&resp).unwrap(); |
||||||
|
resp.get("inner").unwrap().get(0).unwrap().clone() |
||||||
|
} |
||||||
|
|
||||||
|
async fn get<S: AsRef<str>>(_url: S) -> Value { |
||||||
|
let req = reqwest::get(url(_url)); |
||||||
|
unpack(req).await |
||||||
|
} |
||||||
|
|
||||||
|
#[tokio::test] |
||||||
|
async fn test_first_connection() -> TestResult { |
||||||
|
let agent_uid = Uuid::new_v4(); |
||||||
|
let resp = get(format!("get_agent_jobs/{}", agent_uid)).await; |
||||||
|
let job_id = &resp["job_id"]; |
||||||
|
let resp = get(format!("get_jobs/{}", job_id)).await; |
||||||
|
assert_eq!(&resp["alias"], "agent_hello"); |
||||||
|
Ok(()) |
||||||
|
} |
@ -0,0 +1 @@ |
|||||||
|
mod behaviour; |
Loading…
Reference in new issue