()
| 142 | /// <https://github.com/launchbadge/sqlx/issues/1147> |
| 143 | #[tokio::test(flavor = "multi_thread", worker_threads = 2)] |
| 144 | async fn test_db_reopen() -> Result<()> { |
| 145 | use tempfile::tempdir; |
| 146 | |
| 147 | // The context is used only for logging. |
| 148 | let t = TestContext::new().await; |
| 149 | |
| 150 | // Create a separate empty database for testing. |
| 151 | let dir = tempdir()?; |
| 152 | let dbfile = dir.path().join("testdb.sqlite"); |
| 153 | let sql = Sql::new(dbfile); |
| 154 | |
| 155 | // Create database with all the tables. |
| 156 | sql.open(&t, "".to_string()).await.unwrap(); |
| 157 | sql.close().await; |
| 158 | |
| 159 | // Reopen the database |
| 160 | sql.open(&t, "".to_string()).await?; |
| 161 | sql.execute( |
| 162 | "INSERT INTO config (keyname, value) VALUES (?, ?);", |
| 163 | ("foo", "bar"), |
| 164 | ) |
| 165 | .await?; |
| 166 | |
| 167 | let value: Option<String> = sql |
| 168 | .query_get_value("SELECT value FROM config WHERE keyname=?;", ("foo",)) |
| 169 | .await?; |
| 170 | assert_eq!(value.unwrap(), "bar"); |
| 171 | |
| 172 | Ok(()) |
| 173 | } |
| 174 | |
| 175 | #[tokio::test(flavor = "multi_thread", worker_threads = 2)] |
| 176 | async fn test_migration_flags() -> Result<()> { |
nothing calls this directly
no test coverage detected