diff --git a/src/database/mod.rs b/src/database/mod.rs index 7e735d6..53e3016 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -69,11 +69,11 @@ impl Mutation { } #[derive(Clone)] -pub struct Database { +pub struct MoreThanText { schema: Schema, } -impl Database { +impl MoreThanText { pub fn new() -> Self { let tables: Vec = Vec::new(); Self { @@ -93,7 +93,7 @@ impl Database { mod support { use super::*; - pub fn compare(db: &Database, output: &str, expected: &str) { + pub fn compare(db: &MoreThanText, output: &str, expected: &str) { assert!( output == expected, "\n\n{}\nGot: {}\nWant: {}\n\n", @@ -110,7 +110,7 @@ mod queries { #[async_std::test] async fn list_table() { - let db = Database::new(); + let db = MoreThanText::new(); db.execute(r#"mutation {createTable(name: "wilma"){name}}"#) .await; db.execute(r#"mutation {createTable(name: "betty"){name}}"#) @@ -122,7 +122,7 @@ mod queries { #[async_std::test] async fn list_no_table() { - let db = Database::new(); + let db = MoreThanText::new(); let output = db.execute(r#"{table(name: "slade"){name}}"#).await; let expected = r#"{"data":{"table":null}}"#; support::compare(&db, &output, &expected); @@ -130,7 +130,7 @@ mod queries { #[async_std::test] async fn list_tables() { - let db = Database::new(); + let db = MoreThanText::new(); db.execute(r#"mutation {createTable(name: "fred"){name}}"#) .await; db.execute(r#"mutation {createTable(name: "barney"){name}}"#) @@ -142,7 +142,7 @@ mod queries { #[async_std::test] async fn empty_table_description() { - let db = Database::new(); + let db = MoreThanText::new(); let output = db .execute(r#"mutation {createTable(name: "pebbles"){name describe}}"#) .await; @@ -157,7 +157,7 @@ mod mutations { #[async_std::test] async fn add_table() { - let db = Database::new(); + let db = MoreThanText::new(); let output = db .execute(r#"mutation {createTable(name: "william"){name}}"#) .await; @@ -167,7 +167,7 @@ mod mutations { #[async_std::test] async fn cannot_add_duplicate_table() { - let db = Database::new(); + let db = MoreThanText::new(); let qry = r#"mutation {createTable(name: "gadzoo"){name}}"#; db.execute(&qry).await; let output = db.execute(qry).await; diff --git a/src/main.rs b/src/main.rs index e5c1577..8c179d2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,7 @@ use tide::{ mod database; mod settings; -use database::Database; +use database::MoreThanText; use settings::Settings; #[async_std::main] @@ -19,8 +19,8 @@ async fn main() -> tide::Result<()> { Ok(()) } -async fn app_setup() -> tide::Server { - let db = Database::new(); +async fn app_setup() -> tide::Server { + let db = MoreThanText::new(); let mut app = tide::with_state(db); app.at("/").get(home); app.with( @@ -30,7 +30,7 @@ async fn app_setup() -> tide::Server { return app; } -async fn home(_req: Request) -> tide::Result { +async fn home(_req: Request) -> tide::Result { let mut res = Response::new(StatusCode::Ok); res.set_body("