Added GraphQL query function.
This commit is contained in:
		
							
								
								
									
										22
									
								
								src/lib.rs
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								src/lib.rs
									
									
									
									
									
								
							@@ -5,4 +5,26 @@ impl Database {
 | 
				
			|||||||
    pub fn new() -> Self {
 | 
					    pub fn new() -> Self {
 | 
				
			||||||
        Self {}
 | 
					        Self {}
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pub async fn query(&self, _qry: &str) -> String {
 | 
				
			||||||
 | 
					        "{data{}}".to_string()
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[cfg(test)]
 | 
				
			||||||
 | 
					mod queries {
 | 
				
			||||||
 | 
					    use super::*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #[async_std::test]
 | 
				
			||||||
 | 
					    async fn empty_table_query() {
 | 
				
			||||||
 | 
					        let expected = "{data{}}";
 | 
				
			||||||
 | 
					        let testdb = Database::new();
 | 
				
			||||||
 | 
					        let output = testdb.query("{tables{name}}").await;
 | 
				
			||||||
 | 
					        assert!(
 | 
				
			||||||
 | 
					            output == expected,
 | 
				
			||||||
 | 
					            "Got '{}' expected '{}'.",
 | 
				
			||||||
 | 
					            output,
 | 
				
			||||||
 | 
					            expected
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user