@@ -24,10 +24,10 @@ var _ io.Closer = &SQLiteBlob{}
24
24
25
25
type driverConnCallback func (* testing.T , * SQLiteConn )
26
26
27
- func blobTestData (t * testing.T , dbname string , rowid int64 , blob []byte , c driverConnCallback ) error {
27
+ func blobTestData (t * testing.T , dbname string , rowid int64 , blob []byte , c driverConnCallback ) {
28
28
db , err := sql .Open ("sqlite3" , "file:/" + dbname + "?vfs=memdb" )
29
29
if err != nil {
30
- return err
30
+ t . Fatal ( err )
31
31
}
32
32
defer db .Close ()
33
33
@@ -43,13 +43,13 @@ func blobTestData(t *testing.T, dbname string, rowid int64, blob []byte, c drive
43
43
44
44
_ , err = db .Exec (query , sql .Named ("rowid" , rowid ), sql .Named ("value" , blob ))
45
45
if err != nil {
46
- return err
46
+ t . Fatal ( err )
47
47
}
48
48
49
49
// Get raw connection
50
50
conn , err := db .Conn (context .Background ())
51
51
if err != nil {
52
- return err
52
+ t . Fatal ( err )
53
53
}
54
54
defer conn .Close ()
55
55
@@ -60,18 +60,16 @@ func blobTestData(t *testing.T, dbname string, rowid int64, blob []byte, c drive
60
60
return nil
61
61
})
62
62
if err != nil {
63
- return err
63
+ t . Fatal ( err )
64
64
}
65
65
defer driverConn .Close ()
66
-
67
- return nil
68
66
}
69
67
70
68
func TestBlobRead (t * testing.T ) {
71
69
rowid := int64 (6581 )
72
70
expected := []byte ("I ❤️ SQLite in \x00 \x01 \x02 …" )
73
71
74
- err := blobTestData (t , "testblobread" , rowid , expected , func (t * testing.T , driverConn * SQLiteConn ) {
72
+ blobTestData (t , "testblobread" , rowid , expected , func (t * testing.T , driverConn * SQLiteConn ) {
75
73
76
74
// Open blob
77
75
blob , err := driverConn .Blob ("main" , "data" , "value" , rowid , 0 )
@@ -117,10 +115,6 @@ func TestBlobRead(t *testing.T) {
117
115
t .Error ("Expected EOF" , err )
118
116
}
119
117
})
120
-
121
- if err != nil {
122
- t .Fatal ("Failed to get raw connection:" , err )
123
- }
124
118
}
125
119
126
120
func TestBlobWrite (t * testing.T ) {
@@ -133,7 +127,7 @@ func TestBlobWrite(t *testing.T) {
133
127
134
128
// Allocate a zero blob
135
129
data := make ([]byte , len (expected ))
136
- err := blobTestData (t , "testblobwrite" , rowid , data , func (t * testing.T , driverConn * SQLiteConn ) {
130
+ blobTestData (t , "testblobwrite" , rowid , data , func (t * testing.T , driverConn * SQLiteConn ) {
137
131
138
132
// Open blob for read/write
139
133
blob , err := driverConn .Blob ("main" , "data" , "value" , rowid , 1 )
@@ -187,16 +181,13 @@ func TestBlobWrite(t *testing.T) {
187
181
}
188
182
189
183
})
190
- if err != nil {
191
- t .Fatal ("Failed to get raw connection:" , err )
192
- }
193
184
}
194
185
195
186
func TestBlobSeek (t * testing.T ) {
196
187
rowid := int64 (6510 )
197
188
data := make ([]byte , 1000 )
198
189
199
- err := blobTestData (t , "testblobseek" , rowid , data , func (t * testing.T , driverConn * SQLiteConn ) {
190
+ blobTestData (t , "testblobseek" , rowid , data , func (t * testing.T , driverConn * SQLiteConn ) {
200
191
201
192
// Open blob
202
193
blob , err := driverConn .Blob ("main" , "data" , "value" , rowid , 0 )
@@ -229,7 +220,6 @@ func TestBlobSeek(t *testing.T) {
229
220
{offset : - 2 , whence : io .SeekEnd , expected : end - 1 },
230
221
{offset : - 1 , whence : io .SeekEnd , expected : end },
231
222
{offset : 0 , whence : io .SeekEnd , expected : eof },
232
- {offset : 1 , whence : io .SeekEnd , expected : eof + 1 },
233
223
{offset : - eof , whence : io .SeekEnd , expected : begin },
234
224
}
235
225
@@ -252,8 +242,4 @@ func TestBlobSeek(t *testing.T) {
252
242
}
253
243
254
244
})
255
-
256
- if err != nil {
257
- t .Fatal ("Failed to get raw connection:" , err )
258
- }
259
245
}
0 commit comments