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!("/tdg/{}", 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!("/tdg/{}", VER));
}
}Last updated
ArchConfWorkshopUser:~/environment/rust-tdg/target/debug (master) $ cargo test
Compiling rust-tdg v0.1.0 (/home/ec2-user/environment/rust-tdg)
error[E0425]: cannot find function `get_service_root` in this scope
--> src/tdg_service.rs:7:20
|
7 | assert_eq!(get_service_root(), format!("/tdg/{}", VER));
| ^^^^^^^^^^^^^^^^ not found in this scope
error[E0425]: cannot find value `VER` in this scope
--> src/tdg_service.rs:7:61
|
7 | assert_eq!(get_service_root(), format!("/tdg/{}", VER));
| ^^^ not found in this scope
|
help: consider importing this static
|
3 | use crate::VER;
|
warning: unused import: `super::*`
--> src/tdg_service.rs:3:9
|
3 | use super::*;
| ^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: static is never used: `VER`
--> src/lib.rs:5:1
|
5 | 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-tdg`.
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build faileduse super::*;
pub fn get_service_root() -> String {
format!("/tdg/{}", VER)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_get_service_root() {
assert_eq!(get_service_root(), format!("/tdg/{}", VER));
}
}ArchConfWorkshopUser:~/environment/rust-tdg/target/debug (master) $ cargo test
Compiling rust-tdg v0.1.0 (/home/ec2-user/environment/rust-tdg)
Finished test [unoptimized + debuginfo] target(s) in 1.41s
Running deps/myapp-129460598e9ff740
running 1 test
test tdg_service::tests::test_get_service_root ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Running deps/tdg_service-0fa4453d5955ba5c
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!("/tdg/{}", 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!("/tdg/{}", VER));
}
#[test]
fn test_get_service_path() {
assert_eq!(get_service_path(), format!("/tdg/{}/", 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!("/tdg/{}", VER));
}
#[test]
fn test_get_service_path() {
assert_eq!(get_service_path(), format!("/tdg/{}/", VER));
}
#[test]
fn ok_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!("/tdg/{}", 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())
}
#[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!("/tdg/{}", VER));
}
#[test]
fn test_get_service_path() {
assert_eq!(get_service_path(), format!("/tdg/{}/", VER));
}
#[test]
fn ok_response() {
let req = test::TestRequest::with_header("content-type", "text/plain")
.to_http_request();
let resp = index(req);
assert_eq!(resp.status(), StatusCode::OK);
}
}