Changed database to a less generic name.
This commit is contained in:
parent
5839cb93a2
commit
450e4fb53d
@ -69,11 +69,11 @@ impl Mutation {
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Database {
|
||||
pub struct MoreThanText {
|
||||
schema: Schema<Query, Mutation, EmptySubscription>,
|
||||
}
|
||||
|
||||
impl Database {
|
||||
impl MoreThanText {
|
||||
pub fn new() -> Self {
|
||||
let tables: Vec<Table> = 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;
|
||||
|
@ -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<Database> {
|
||||
let db = Database::new();
|
||||
async fn app_setup() -> tide::Server<MoreThanText> {
|
||||
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<Database> {
|
||||
return app;
|
||||
}
|
||||
|
||||
async fn home(_req: Request<Database>) -> tide::Result {
|
||||
async fn home(_req: Request<MoreThanText>) -> tide::Result {
|
||||
let mut res = Response::new(StatusCode::Ok);
|
||||
res.set_body("<!DOCTYPE html>
|
||||
<html>
|
||||
|
Loading…
Reference in New Issue
Block a user