Skip to content

Commit 0178165

Browse files
committed
test(sqlite): close sqlcipher connections explicitly
1 parent 4563689 commit 0178165

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tests/sqlite/sqlcipher.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ async fn it_encrypts() -> anyhow::Result<()> {
5656
.await?;
5757

5858
fill_db(&mut conn).await?;
59+
conn.close().await?;
5960

6061
// Create another connection without key, query should fail
6162
let mut conn = SqliteConnectOptions::from_str(&url)?.connect().await?;
@@ -67,6 +68,8 @@ async fn it_encrypts() -> anyhow::Result<()> {
6768
.await
6869
.is_err());
6970

71+
conn.close().await?;
72+
7073
Ok(())
7174
}
7275

@@ -81,6 +84,7 @@ async fn it_can_store_and_read_encrypted_data() -> anyhow::Result<()> {
8184
.await?;
8285

8386
fill_db(&mut conn).await?;
87+
conn.close().await?;
8488

8589
// Create another connection with valid key
8690
let mut conn = SqliteConnectOptions::from_str(&url)?
@@ -96,6 +100,8 @@ async fn it_can_store_and_read_encrypted_data() -> anyhow::Result<()> {
96100

97101
assert!(result.len() > 0);
98102

103+
conn.close().await?;
104+
99105
Ok(())
100106
}
101107

@@ -110,6 +116,7 @@ async fn it_fails_if_password_is_incorrect() -> anyhow::Result<()> {
110116
.await?;
111117

112118
fill_db(&mut conn).await?;
119+
conn.close().await?;
113120

114121
// Connection with invalid key should not allow to execute queries
115122
let mut conn = SqliteConnectOptions::from_str(&url)?
@@ -124,6 +131,8 @@ async fn it_fails_if_password_is_incorrect() -> anyhow::Result<()> {
124131
.await
125132
.is_err());
126133

134+
conn.close().await?;
135+
127136
Ok(())
128137
}
129138

@@ -148,6 +157,7 @@ async fn it_honors_order_of_encryption_pragmas() -> anyhow::Result<()> {
148157
.await?;
149158

150159
fill_db(&mut conn).await?;
160+
conn.close().await?;
151161

152162
let mut conn = SqliteConnectOptions::from_str(&url)?
153163
.pragma("dummy", "pragma")
@@ -167,6 +177,8 @@ async fn it_honors_order_of_encryption_pragmas() -> anyhow::Result<()> {
167177

168178
assert!(result.len() > 0);
169179

180+
conn.close().await?;
181+
170182
Ok(())
171183
}
172184

@@ -186,6 +198,7 @@ async fn it_allows_to_rekey_the_db() -> anyhow::Result<()> {
186198
query("PRAGMA rekey = new_password;")
187199
.execute(&mut conn)
188200
.await?;
201+
conn.close().await?;
189202

190203
let mut conn = SqliteConnectOptions::from_str(&url)?
191204
.pragma("dummy", "pragma")
@@ -201,5 +214,7 @@ async fn it_allows_to_rekey_the_db() -> anyhow::Result<()> {
201214

202215
assert!(result.len() > 0);
203216

217+
conn.close().await?;
218+
204219
Ok(())
205220
}

0 commit comments

Comments
 (0)