Created
November 8, 2021 00:12
-
-
Save jayhuang75/bf81ebdecbd558683469ad5ed6027a7c to your computer and use it in GitHub Desktop.
go train delay rust api json to sql unit test
This file contains hidden or 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
| #[actix_rt::test] | |
| async fn test_to_sql_query_ranges_must() { | |
| let query = r#"select date, departure, depart_scheduled, destination, arrival_scheduled, delay, created_at, count(*) OVER() AS total_count from delays WHERE ( date >= '"2017-01-01"' AND date <= '"2017-06-30"' )"#; | |
| let query_str = r#" | |
| { | |
| "query": { | |
| "must": { | |
| "ranges": [ | |
| {"date": {"gte": "2017-01-01", "lte": "2017-06-30"}} | |
| ] | |
| } | |
| } | |
| }"#; | |
| let raw_query = build_query(query_str).expect("test new query builder failed"); | |
| let sql_query = raw_query | |
| .to_sql_query(SEARCH_NAMESPACE_DATE_RANGE) | |
| .await | |
| .unwrap(); | |
| assert_eq!(sql_query.sql, query); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment