@@ -20,7 +20,8 @@ func TestParseConnectionString(t *testing.T) {
2020 Password : "" ,
2121 Database : "mydatabase" ,
2222 Timeout : time .Duration (11 ) * time .Second ,
23- CompressMode : "YES" ,
23+ Compression : true ,
24+ CompressMode : sqlitecloud .CompressModeLZ4 ,
2425 Secure : true ,
2526 TlsInsecureSkipVerify : false ,
2627 Pem : "" ,
@@ -50,7 +51,8 @@ func TestParseConnectionStringWithAPIKey(t *testing.T) {
5051 Password : "pass" ,
5152 Database : "dbname" ,
5253 Timeout : time .Duration (11 ) * time .Second ,
53- CompressMode : "TRUE" ,
54+ Compression : true ,
55+ CompressMode : sqlitecloud .CompressModeLZ4 ,
5456 Secure : true ,
5557 TlsInsecureSkipVerify : false ,
5658 Pem : "" ,
@@ -104,8 +106,8 @@ func TestParseConnectionStringWithParameters(t *testing.T) {
104106 {
105107 param : "compression" ,
106108 configParam : "Compression" ,
107- value : "true " ,
108- expectedValue : true ,
109+ value : "false " ,
110+ expectedValue : false ,
109111 },
110112 {
111113 param : "zerotext" ,
@@ -203,6 +205,104 @@ func TestParseConnectionStringWithParameters(t *testing.T) {
203205 }
204206}
205207
208+ func TestParseConnectionStringCompressionCombinations (t * testing.T ) {
209+ tests := []struct {
210+ param string
211+ configParam string
212+ value string
213+ expectedValue any
214+ }{
215+ {
216+ param : "compression" ,
217+ configParam : "Compression" ,
218+ value : "false" ,
219+ expectedValue : false ,
220+ },
221+ {
222+ param : "compression" ,
223+ configParam : "Compression" ,
224+ value : "disabled" ,
225+ expectedValue : false ,
226+ },
227+ {
228+ param : "compression" ,
229+ configParam : "Compression" ,
230+ // value not supported
231+ value : "no" ,
232+ expectedValue : true ,
233+ },
234+ {
235+ param : "compression" ,
236+ configParam : "Compression" ,
237+ value : "0" ,
238+ expectedValue : false ,
239+ },
240+ {
241+ param : "compression" ,
242+ configParam : "Compression" ,
243+ value : "true" ,
244+ expectedValue : true ,
245+ },
246+ {
247+ param : "compression" ,
248+ configParam : "Compression" ,
249+ value : "enabled" ,
250+ expectedValue : true ,
251+ },
252+ {
253+ param : "compression" ,
254+ configParam : "Compression" ,
255+ value : "yes" ,
256+ expectedValue : true ,
257+ },
258+ {
259+ param : "compression" ,
260+ configParam : "Compression" ,
261+ value : "1" ,
262+ expectedValue : true ,
263+ },
264+ {
265+ param : "compress" ,
266+ configParam : "CompressMode" ,
267+ value : "lz4" ,
268+ expectedValue : sqlitecloud .CompressModeLZ4 ,
269+ },
270+ {
271+ param : "compress" ,
272+ configParam : "Compression" ,
273+ value : "lz4" ,
274+ expectedValue : true ,
275+ },
276+ {
277+ param : "compress" ,
278+ configParam : "CompressMode" ,
279+ value : "no" ,
280+ expectedValue : sqlitecloud .CompressModeNo ,
281+ },
282+ {
283+ param : "compress" ,
284+ configParam : "Compression" ,
285+ value : "no" ,
286+ expectedValue : false ,
287+ },
288+ }
289+
290+ for _ , tt := range tests {
291+ t .Run (tt .param , func (t * testing.T ) {
292+ config , err := sqlitecloud .ParseConnectionString ("sqlitecloud://myhost.sqlite.cloud/mydatabase?" + tt .param + "=" + tt .value )
293+
294+ assert .NoError (t , err )
295+
296+ actualValue := reflect .ValueOf (* config ).FieldByName (tt .configParam )
297+ if ! actualValue .IsValid () {
298+ t .Fatalf ("Field %s not found in config" , tt .configParam )
299+ } else {
300+ assert .Equal (t , tt .expectedValue , actualValue .Interface ())
301+ }
302+ })
303+ }
304+ }
305+
206306func TestParseConnectionStringWithTLSParameter (t * testing.T ) {
207307 tests := []struct {
208308 tlsValue string
0 commit comments