@@ -104,7 +104,7 @@ fn load_namespace_from_dump_from_file() {
104104
105105#[ test]
106106#[ ignore = "need to remove block in place in load dump, wait for #693" ]
107- fn load_namespace_from_invalid_dump ( ) {
107+ fn load_namespace_from_no_commit ( ) {
108108 const DUMP : & str = r#"
109109 PRAGMA foreign_keys=OFF;
110110 BEGIN TRANSACTION;
@@ -123,8 +123,45 @@ fn load_namespace_from_invalid_dump() {
123123 sim. client ( "client" , async move {
124124 let client = Client :: new ( ) ;
125125 let resp = client. post ( "http://primary:9090/v1/namespaces/foo/create" , json ! ( { "dump_url" : format!( "file:{}" , tmp_path. join( "dump.sql" ) . display( ) ) } ) ) . await . unwrap ( ) ;
126- assert_eq ! ( resp. status( ) , StatusCode :: OK , "{}" , resp. json:: <serde_json:: Value >( ) . await . unwrap_or_default( ) ) ;
126+ // the dump is malformed
127+ assert_eq ! ( resp. status( ) , StatusCode :: BAD_REQUEST , "{}" , resp. json:: <serde_json:: Value >( ) . await . unwrap_or_default( ) ) ;
128+
129+ // namespace doesn't exist
130+ let foo = Database :: open_remote_with_connector ( "http://foo.primary:8080" , "" , TurmoilConnector ) ?;
131+ let foo_conn = foo. connect ( ) ?;
132+ assert ! ( foo_conn. query( "select count(*) from test" , ( ) ) . await . is_err( ) ) ;
133+
134+ Ok ( ( ) )
135+ } ) ;
136+
137+ sim. run ( ) . unwrap ( ) ;
138+ }
139+
140+ #[ test]
141+ #[ ignore = "need to remove block in place in load dump, wait for #693" ]
142+ fn load_namespace_from_no_txn ( ) {
143+ const DUMP : & str = r#"
144+ PRAGMA foreign_keys=OFF;
145+ CREATE TABLE test (x);
146+ INSERT INTO test VALUES(42);
147+ COMMIT;
148+ "# ;
149+
150+ let mut sim = Builder :: new ( ) . build ( ) ;
151+ let tmp = tempdir ( ) . unwrap ( ) ;
152+ let tmp_path = tmp. path ( ) . to_path_buf ( ) ;
153+
154+ std:: fs:: write ( tmp_path. join ( "dump.sql" ) , & DUMP ) . unwrap ( ) ;
155+
156+ make_primary ( & mut sim, tmp. path ( ) . to_path_buf ( ) ) ;
157+
158+ sim. client ( "client" , async move {
159+ let client = Client :: new ( ) ;
160+ let resp = client. post ( "http://primary:9090/v1/namespaces/foo/create" , json ! ( { "dump_url" : format!( "file:{}" , tmp_path. join( "dump.sql" ) . display( ) ) } ) ) . await . unwrap ( ) ;
161+ // the dump is malformed
162+ assert_eq ! ( resp. status( ) , StatusCode :: BAD_REQUEST , "{}" , resp. json:: <serde_json:: Value >( ) . await . unwrap_or_default( ) ) ;
127163
164+ // namespace doesn't exist
128165 let foo = Database :: open_remote_with_connector ( "http://foo.primary:8080" , "" , TurmoilConnector ) ?;
129166 let foo_conn = foo. connect ( ) ?;
130167 assert ! ( foo_conn. query( "select count(*) from test" , ( ) ) . await . is_err( ) ) ;
0 commit comments