Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jayhuang75/bf81ebdecbd558683469ad5ed6027a7c to your computer and use it in GitHub Desktop.

Select an option

Save jayhuang75/bf81ebdecbd558683469ad5ed6027a7c to your computer and use it in GitHub Desktop.
go train delay rust api json to sql unit test
#[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