@@ -4,74 +4,46 @@ namespace DuckDB.JWT.Tests;
44
55public class DuckDBExtensionFixture : IDisposable
66{
7- private readonly DuckDBConnection connection ;
8- private readonly string extensionDirectory ;
97 private bool disposed ;
108
119 public DuckDBExtensionFixture ( )
1210 {
13- // Set up custom extension directory
14- extensionDirectory = Path . Combine ( AppContext . BaseDirectory , "extensions-install" ) ;
15-
16- try
17- {
18- if ( Directory . Exists ( extensionDirectory ) )
19- {
20- Directory . Delete ( extensionDirectory , recursive : true ) ;
21- }
22- }
23- catch { }
11+ var extensionDirectory = Path . Combine ( AppContext . BaseDirectory , "extensions-install" ) ;
2412
2513 Directory . CreateDirectory ( extensionDirectory ) ;
2614
2715 // Allow unsigned extensions and set custom extension directory
2816 var connectionString = $ "DataSource=:memory:;allow_unsigned_extensions=true;extension_directory={ extensionDirectory } ";
29- connection = new DuckDBConnection ( connectionString ) ;
30- connection . Open ( ) ;
17+ Connection = new DuckDBConnection ( connectionString ) ;
18+ Connection . Open ( ) ;
3119
3220 LoadJwtExtension ( ) ;
3321 }
3422
35- public DuckDBConnection Connection => connection ;
23+ public DuckDBConnection Connection { get ; }
3624
3725 private void LoadJwtExtension ( )
3826 {
39- var extensionPath = GetExtensionPath ( ) ;
27+ var extensionPath = Path . Combine ( AppContext . BaseDirectory , "extensions" , "jwt.duckdb_extension" ) ;
4028
4129 if ( ! File . Exists ( extensionPath ) )
4230 {
4331 throw new FileNotFoundException ( $ "JWT extension not found at: { extensionPath } ") ;
4432 }
4533
46- using var command = connection . CreateCommand ( ) ;
34+ using var command = Connection . CreateCommand ( ) ;
4735 command . CommandText = $ "INSTALL '{ extensionPath } ';";
4836 command . ExecuteNonQuery ( ) ;
4937
5038 command . CommandText = "LOAD jwt;" ;
5139 command . ExecuteNonQuery ( ) ;
5240 }
5341
54- private static string GetExtensionPath ( )
55- {
56- var baseDirectory = AppContext . BaseDirectory ;
57- var extensionPath = Path . Combine ( baseDirectory , "extensions" , "jwt.duckdb_extension" ) ;
58- return extensionPath ;
59- }
60-
6142 public void Dispose ( )
6243 {
6344 if ( disposed ) return ;
6445
65- connection ? . Dispose ( ) ;
66-
67- try
68- {
69- if ( Directory . Exists ( extensionDirectory ) )
70- {
71- Directory . Delete ( extensionDirectory , recursive : true ) ;
72- }
73- }
74- catch { }
46+ Connection ? . Dispose ( ) ;
7547
7648 disposed = true ;
7749 GC . SuppressFinalize ( this ) ;
0 commit comments