File tree Expand file tree Collapse file tree 5 files changed +15
-13
lines changed Expand file tree Collapse file tree 5 files changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -19,8 +19,10 @@ serde.workspace = true
1919serde_json.workspace = true
2020pg_diagnostics.workspace = true
2121pg_console.workspace = true
22-
2322sqlx.workspace = true
2423
24+ [dev-dependencies ]
25+ pg_test_utils.workspace = true
26+
2527[lib ]
2628doctest = false
Original file line number Diff line number Diff line change @@ -75,17 +75,16 @@ pub trait SchemaCacheItem {
7575
7676#[ cfg( test) ]
7777mod tests {
78- use sqlx:: PgPool ;
78+ use async_std:: task:: block_on;
79+ use pg_test_utils:: test_database:: get_new_test_db;
7980
8081 use crate :: SchemaCache ;
8182
8283 #[ test]
8384 fn test_schema_cache ( ) {
84- let conn_string = std :: env :: var ( "DATABASE_URL" ) . unwrap ( ) ;
85+ let test_db = block_on ( get_new_test_db ( ) ) ;
8586
86- let pool = async_std:: task:: block_on ( PgPool :: connect ( conn_string. as_str ( ) ) ) . unwrap ( ) ;
87-
88- async_std:: task:: block_on ( SchemaCache :: load ( & pool) ) . expect ( "Couldn't load Schema Cache" ) ;
87+ block_on ( SchemaCache :: load ( & test_db) ) . expect ( "Couldn't load Schema Cache" ) ;
8988
9089 assert ! ( true ) ;
9190 }
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ async-std = "1.12.0"
2424
2525
2626[dev-dependencies ]
27+ pg_test_utils.workspace = true
2728
2829[lib ]
2930doctest = false
Original file line number Diff line number Diff line change @@ -85,23 +85,21 @@ pub async fn check_sql<'a>(params: TypecheckerParams<'a>) -> Vec<TypeError> {
8585#[ cfg( test) ]
8686mod tests {
8787 use async_std:: task:: block_on;
88- use sqlx :: PgPool ;
88+ use pg_test_utils :: test_database :: get_new_test_db ;
8989
9090 use crate :: { check_sql, TypecheckerParams } ;
9191
9292 #[ test]
93- fn test_check_sql ( ) {
93+ fn test_basic_type ( ) {
9494 let input = "select id, unknown from contact;" ;
9595
96- let conn_string = std:: env:: var ( "DATABASE_URL" ) . unwrap ( ) ;
97-
98- let pool = block_on ( PgPool :: connect ( conn_string. as_str ( ) ) ) . unwrap ( ) ;
96+ let test_db = block_on ( get_new_test_db ( ) ) ;
9997
10098 let root = pg_query_ext:: parse ( input) . unwrap ( ) ;
10199 let ast = pg_syntax:: parse_syntax ( input, & root) . ast ;
102100
103101 let errs = block_on ( check_sql ( TypecheckerParams {
104- conn : & pool ,
102+ conn : & test_db ,
105103 sql : input,
106104 ast : & root,
107105 enriched_ast : Some ( & ast) ,
@@ -111,6 +109,6 @@ mod tests {
111109
112110 let e = & errs[ 0 ] ;
113111
114- assert_eq ! ( & input[ e. range. unwrap( ) ] , "unknown " ) ;
112+ assert_eq ! ( & input[ e. range. unwrap( ) ] , "contact " ) ;
115113 }
116114}
You can’t perform that action at this time.
0 commit comments