Added not table return.
This commit is contained in:
		
							
								
								
									
										14
									
								
								src/lib.rs
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/lib.rs
									
									
									
									
									
								
							@@ -31,8 +31,10 @@ impl Query {
 | 
				
			|||||||
            .read()
 | 
					            .read()
 | 
				
			||||||
            .await
 | 
					            .await
 | 
				
			||||||
            .to_vec();
 | 
					            .to_vec();
 | 
				
			||||||
        let idx = tbls.binary_search_by(|t| t.name.cmp(&name)).unwrap();
 | 
					        match tbls.binary_search_by(|t| t.name.cmp(&name)) {
 | 
				
			||||||
        Ok(Some(tbls[idx].clone()))
 | 
					            Ok(idx) => Ok(Some(tbls[idx].clone())),
 | 
				
			||||||
 | 
					            Err(_) => Ok(None),
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async fn tables(&self, ctx: &Context<'_>) -> Vec<Table> {
 | 
					    async fn tables(&self, ctx: &Context<'_>) -> Vec<Table> {
 | 
				
			||||||
@@ -109,6 +111,14 @@ mod queries {
 | 
				
			|||||||
        support::compare(&db, &output, &expected);
 | 
					        support::compare(&db, &output, &expected);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #[async_std::test]
 | 
				
			||||||
 | 
					    async fn list_no_table() {
 | 
				
			||||||
 | 
					        let db = Database::new();
 | 
				
			||||||
 | 
					        let output = db.execute(r#"{table(name: "slade"){name}}"#).await;
 | 
				
			||||||
 | 
					        let expected = r#"{"data":{"table":null}}"#;
 | 
				
			||||||
 | 
					        support::compare(&db, &output, &expected);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #[async_std::test]
 | 
					    #[async_std::test]
 | 
				
			||||||
    async fn list_tables() {
 | 
					    async fn list_tables() {
 | 
				
			||||||
        let db = Database::new();
 | 
					        let db = Database::new();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user