diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8ff86d8919fe0f08c53f6a33889c995e9a866edf..faf35b1c04b21a3e9d66b9746a0faa37f8c8a415 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,3 +4,19 @@ test:cargo: script: - rustc --version && cargo --version # Print version info for debugging - cargo test --workspace --verbose + +build:release: + stage: build + script: + - cargo build --release + artifacts: + paths: + - target/release/webcalc-rs + +rustdoc: + stage: build + script: + - cargo doc + artefacts: + paths: + - target/doc diff --git a/src/main.rs b/src/main.rs index 06a4c987046575f85b2f339bba66e1d984ea1f7a..4473924a0e4bbcc6f6b15a9d6308ea81ddfe87a4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,7 +33,7 @@ Les opérations possibles sont: Pour envoyer une requête avec curl: -curl -X POST http://<host> -H 'Content-Type: application/json' -d '{"Plus": [3, 4]}' +curl -X POST http://HOST_URI -H 'Content-Type: application/json' -d '{"Plus": [3, 4]}' "#; mod operations; @@ -41,7 +41,7 @@ use operations::{Operation, OperationResult}; #[get("/")] fn index(host: &Host) -> String { - INDEX_TEXT.replace("<host>", &host.to_string()) + INDEX_TEXT.replace("HOST_URI", &host.to_string()) } #[post("/", data = "<operation>")] @@ -66,6 +66,7 @@ fn launch() -> _ { mod tests { use super::*; use rocket::http::Status; + use rocket::http::uri::Host; use rocket::local::blocking::Client; use rocket::uri; @@ -82,10 +83,10 @@ mod tests { #[test] fn index() { let client = Client::tracked(launch()).expect("valid rocket instance"); - let response = client.get(uri!(index)).dispatch(); + let mut req = client.get(uri!(index)); + req.set_host(Host::from(uri!("HOST_URI"))); + let response = req.dispatch(); assert_eq!(response.status(), Status::Ok); - - assert_eq!(response.into_string().unwrap(), super::INDEX_TEXT); } #[test]