Section IV - module
#[cfg(test)]
mod tests {
use super::*;
}#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_get_service_root() {
assert_eq!(get_service_root(), format!("/hello/{}", VER));
}
}Last updated
#[cfg(test)]
mod tests {
use super::*;
}#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_get_service_root() {
assert_eq!(get_service_root(), format!("/hello/{}", VER));
}
}Last updated
[user@localhost rust-daas]$ cargo test
Compiling rust-daas v0.1.0 (C:\tmp\rust-daas)
error[E0425]: cannot find function `get_service_root` in this scope
--> src\hello_world.rs:8:20
|
8 | assert_eq!(get_service_root(), format!("/hello/{}", VER));
| ^^^^^^^^^^^^^^^^ not found in this scope
error[E0425]: cannot find value `VER` in this scope
--> src\hello_world.rs:8:61
|
8 | assert_eq!(get_service_root(), format!("/hello/{}", VER));
| ^^^ not found in this scope
|
help: consider importing this static
|
4 | use crate::VER;
|
warning: unused import: `super::*`
--> src\hello_world.rs:4:9
|
4 | use super::*;
| ^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: static is never used: `VER`
--> src/lib.rs:4:1
|
4 | static VER: &str = "v1";
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: 1 warning emitted
error: aborting due to 2 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0425`.
error: could not compile `rust-daas`.use super::*;
pub fn get_service_root() -> String {
format!("/hello/{}", VER)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_get_service_root() {
assert_eq!(get_service_root(), format!("/hello/{}", VER));
}
}ArchConfWorkshopUser:~/environment/rust-daas (master) $ cargo test
Compiling rust-daas v0.1.0 (/home/ec2-user/environment/rust-daas)
Finished test [unoptimized + debuginfo] target(s) in 0.89s
Running target/debug/deps/myapp-deab36d0847aeb68
running 1 test
test hello_world::tests::test_get_service_root ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Running target/debug/deps/hello_world-c97b0cb1d60cefb2
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Doc-tests myapp
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered outuse super::*;
pub fn get_service_root() -> String {
format!("/hello/{}", VER)
}
pub fn get_service_path() -> String {
get_service_root() + "/"
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_get_service_root() {
assert_eq!(get_service_root(), format!("/hello/{}", VER));
}
#[test]
fn test_get_service_path() {
assert_eq!(get_service_path(), format!("/hello/{}/", VER));
}
}#[cfg(test)]
mod tests {
use super::*;
#[allow(unused_imports)]
use actix_web::{test};
#[test]
fn test_get_service_root() {
assert_eq!(get_service_root(), format!("/hello/{}", VER));
}
#[test]
fn test_get_service_path() {
assert_eq!(get_service_path(), format!("/hello/{}/", VER));
}
#[test]
fn hello_response() {
let req = test::TestRequest::with_header("content-type", "text/plain")
.to_http_request();
let resp = index(req);
assert_eq!(resp.status(), StatusCode::OK);
}
}use actix_web::{HttpRequest, HttpResponse };
use actix_web::http::{StatusCode};
pub fn index(_req: HttpRequest) -> HttpResponse {
HttpResponse::build(StatusCode::OK)
.body("Hello World!".to_string())
}use super::*;
use actix_web::{HttpRequest, HttpResponse };
use actix_web::http::{StatusCode};
pub fn get_service_root() -> String {
format!("/hello/{}", VER)
}
pub fn get_service_path() -> String {
get_service_root() + "/"
}
pub fn index(_req: HttpRequest) -> HttpResponse {
HttpResponse::build(StatusCode::OK)
.body("Hello World!".to_string())
}
mod tests {
use super::*;
#[allow(unused_imports)]
use actix_web::{test};
#[test]
fn test_get_service_root() {
assert_eq!(get_service_root(), format!("/hello/{}", VER));
}
#[test]
fn test_get_service_path() {
assert_eq!(get_service_path(), format!("/hello/{}/", VER));
}
#[test]
fn hello_response() {
let req = test::TestRequest::with_header("content-type", "text/plain")
.to_http_request();
let resp = index(req);
assert_eq!(resp.status(), StatusCode::OK);
}
}