MCPcopy Create free account
hub / github.com/chatmail/core / test_db_reopen

Function test_db_reopen

src/sql/sql_tests.rs:144–173  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

142/// <https://github.com/launchbadge/sqlx/issues/1147>
143#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
144async 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)]
176async fn test_migration_flags() -> Result<()> {

Callers

nothing calls this directly

Calls 4

executeMethod · 0.80
query_get_valueMethod · 0.80
openMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected