-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c778ca1
commit c8096c6
Showing
4 changed files
with
52 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#![forbid(unsafe_code)] | ||
|
||
#[macro_use] | ||
extern crate rocket; | ||
|
||
#[get("/")] | ||
pub fn map_root() -> &'static str { | ||
"Map of Bartlesville recycling options" | ||
} | ||
|
||
#[get("/map")] | ||
pub fn map() -> &'static str { | ||
"Map of Bartlesville recycling options" | ||
} | ||
|
||
pub fn rocket() -> rocket::Rocket<rocket::Build> { | ||
rocket::build().mount("/", routes![map_root, map]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,9 @@ | ||
#![forbid(unsafe_code)] | ||
|
||
#[macro_use] extern crate rocket; | ||
|
||
|
||
|
||
#[get("/")] | ||
fn map_root() -> &'static str { | ||
"Map of Bartlesville recycling options" | ||
} | ||
|
||
#[get("/map")] | ||
fn map() -> &'static str { | ||
"Map of Bartlesville recycling options" | ||
} | ||
use bville_recycle::rocket as app_rocket; | ||
use rocket::launch; // Rename the imported function | ||
|
||
#[launch] | ||
fn rocket() -> _ { | ||
rocket::build() | ||
.mount("/", routes![map_root, map]) | ||
} | ||
|
||
/* | ||
_____ _ _ _____ | ||
|_ _|__ ___| |_(_)_ __ __ _ |__ /___ _ __ ___ | ||
| |/ _ \/ __| __| | '_ \ / _` | / // _ \| '_ \ / _ \ | ||
| | __/\__ \ |_| | | | | (_| | / /| (_) | | | | __/ | ||
|_|\___||___/\__|_|_| |_|\__, | /____\___/|_| |_|\___| | ||
|___/ | ||
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ | ||
*/ | ||
|
||
#[cfg(test)] // Ensure this block is only included during testing | ||
mod tests { | ||
use super::*; // Import functions and routes from the main module | ||
use rocket::local::blocking::Client; // Import the blocking client for testing | ||
use rocket::http::Status; // Import HTTP status for response checks | ||
|
||
#[test] // Tests the map_root function | ||
fn test_map_root() { | ||
let rocket = rocket::build() | ||
.mount("/", routes![map_root]); | ||
let client = Client::tracked(rocket).expect("valid rocket instance"); | ||
let response = client.get("/").dispatch(); | ||
assert_eq!(response.status(), Status::Ok); | ||
assert_eq!( | ||
response.into_string(), | ||
Some("Map of Bartlesville recycling options".into()) | ||
); | ||
} | ||
|
||
#[test] // Tests the map function | ||
fn test_map() { | ||
let rocket = rocket::build() | ||
.mount("/", routes![map]); | ||
let client = Client::tracked(rocket).expect("valid rocket instance"); | ||
let response = client.get("/map").dispatch(); | ||
assert_eq!(response.status(), Status::Ok); | ||
assert_eq!( | ||
response.into_string(), | ||
Some("Map of Bartlesville recycling options".into()) | ||
); | ||
} | ||
app_rocket() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use bville_recycle::rocket; | ||
use rocket::http::Status; // Import HTTP status for response checks | ||
use rocket::local::blocking::Client; // Import the blocking client for testing // Import the rocket function from the library | ||
|
||
#[test] // Tests the map_root function | ||
fn test_map_root() { | ||
let rocket = rocket(); | ||
let client = Client::tracked(rocket).expect("valid rocket instance"); | ||
let response = client.get("/").dispatch(); | ||
assert_eq!(response.status(), Status::Ok); | ||
assert_eq!( | ||
response.into_string(), | ||
Some("Map of Bartlesville recycling options".into()) | ||
); | ||
} | ||
|
||
#[test] // Tests the map function | ||
fn test_map() { | ||
let rocket = rocket(); | ||
let client = Client::tracked(rocket).expect("valid rocket instance"); | ||
let response = client.get("/map").dispatch(); | ||
assert_eq!(response.status(), Status::Ok); | ||
assert_eq!( | ||
response.into_string(), | ||
Some("Map of Bartlesville recycling options".into()) | ||
); | ||
} |