@@ -70,8 +70,29 @@ func TestNamespace(t *testing.T) {
70
70
namespace .connectionString , "The connection string should be correct" )
71
71
})
72
72
73
+ t .Run ("The connection string is set correctly for a read-only file DB" , func (t * testing.T ) {
74
+ var err error
75
+ namespace , err = NewNamespace (NamespaceConfig {
76
+ ReadOnly : true ,
77
+ })
78
+ require .NoError (t , err , "The namespace should be initialized" )
79
+ require .Equal (t , "file:anyquery.db?cache=shared&mode=ro&_cache_size=-50000&_journal_mode=WAL&_synchronous=NORMAL&_foreign_keys=OFF" ,
80
+ namespace .connectionString , "The connection string should be correct" )
81
+ })
82
+
83
+ t .Run ("The read only flag is ignored for in-memory DB" , func (t * testing.T ) {
84
+ var err error
85
+ namespace , err = NewNamespace (NamespaceConfig {
86
+ ReadOnly : true ,
87
+ InMemory : true ,
88
+ })
89
+ require .NoError (t , err , "The namespace should be initialized" )
90
+ require .Equal (t , "file:anyquery.db?cache=shared&mode=memory&_cache_size=-50000&_journal_mode=WAL&_synchronous=NORMAL&_foreign_keys=OFF" ,
91
+ namespace .connectionString , "The connection string should be correct" )
92
+ })
93
+
73
94
t .Run ("The GetConnectionString method works" , func (t * testing.T ) {
74
- require .Equal (t , "file:mytest .db?cache=shared&_foreign_keys=OFF" ,
95
+ require .Equal (t , "file:anyquery .db?cache=shared&mode=memory&_cache_size=-50000&_journal_mode=WAL&_synchronous=NORMAL &_foreign_keys=OFF" ,
75
96
namespace .GetConnectionString (), "The connection string should be correct" )
76
97
require .Equal (t , namespace .connectionString , namespace .GetConnectionString (), "The connection string should be correct" )
77
98
})
0 commit comments