@@ -11,14 +11,17 @@ import (
11
11
"time"
12
12
)
13
13
14
+ // Dialect is a type of dialect of databases.
14
15
type Dialect int
15
16
17
+ // Dialects for databases.
16
18
const (
17
- SQLITE Dialect = iota
18
- POSTGRESQL
19
- MYSQL
19
+ SQLITE Dialect = iota // SQLITE mean SQLite3 dialect
20
+ POSTGRESQL // POSTGRESQL mean PostgreSQL dialect
21
+ MYSQL // MYSQL mean MySQL dialect
20
22
)
21
23
24
+ // DB provide context for the tests
22
25
type DB struct {
23
26
* testing.T
24
27
* sql.DB
@@ -149,6 +152,7 @@ func makeBench() {
149
152
}
150
153
}
151
154
155
+ // TestResult is test for result
152
156
func TestResult (t * testing.T ) {
153
157
db .tearDown ()
154
158
db .mustExec ("create temporary table test (id " + db .serialPK () + ", name varchar(10))" )
@@ -175,6 +179,7 @@ func TestResult(t *testing.T) {
175
179
}
176
180
}
177
181
182
+ // TestBlobs is test for blobs
178
183
func TestBlobs (t * testing.T ) {
179
184
db .tearDown ()
180
185
var blob = []byte {0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 }
@@ -201,6 +206,7 @@ func TestBlobs(t *testing.T) {
201
206
}
202
207
}
203
208
209
+ // TestManyQueryRow is test for many query row
204
210
func TestManyQueryRow (t * testing.T ) {
205
211
if testing .Short () {
206
212
t .Log ("skipping in short mode" )
@@ -218,6 +224,7 @@ func TestManyQueryRow(t *testing.T) {
218
224
}
219
225
}
220
226
227
+ // TestTxQuery is test for transactional query
221
228
func TestTxQuery (t * testing.T ) {
222
229
db .tearDown ()
223
230
tx , err := db .Begin ()
@@ -256,6 +263,7 @@ func TestTxQuery(t *testing.T) {
256
263
}
257
264
}
258
265
266
+ // TestPreparedStmt is test for prepared statement
259
267
func TestPreparedStmt (t * testing.T ) {
260
268
db .tearDown ()
261
269
db .mustExec ("CREATE TABLE t (count INT)" )
@@ -301,6 +309,7 @@ func TestPreparedStmt(t *testing.T) {
301
309
// test -bench but calling Benchmark() from a benchmark test
302
310
// currently hangs go.
303
311
312
+ // BenchmarkExec is benchmark for exec
304
313
func BenchmarkExec (b * testing.B ) {
305
314
for i := 0 ; i < b .N ; i ++ {
306
315
if _ , err := db .Exec ("select 1" ); err != nil {
@@ -309,6 +318,7 @@ func BenchmarkExec(b *testing.B) {
309
318
}
310
319
}
311
320
321
+ // BenchmarkQuery is benchmark for query
312
322
func BenchmarkQuery (b * testing.B ) {
313
323
for i := 0 ; i < b .N ; i ++ {
314
324
var n sql.NullString
@@ -322,6 +332,7 @@ func BenchmarkQuery(b *testing.B) {
322
332
}
323
333
}
324
334
335
+ // BenchmarkParams is benchmark for params
325
336
func BenchmarkParams (b * testing.B ) {
326
337
for i := 0 ; i < b .N ; i ++ {
327
338
var n sql.NullString
@@ -335,6 +346,7 @@ func BenchmarkParams(b *testing.B) {
335
346
}
336
347
}
337
348
349
+ // BenchmarkStmt is benchmark for statement
338
350
func BenchmarkStmt (b * testing.B ) {
339
351
st , err := db .Prepare ("select ?, ?, ?, ?" )
340
352
if err != nil {
@@ -354,6 +366,7 @@ func BenchmarkStmt(b *testing.B) {
354
366
}
355
367
}
356
368
369
+ // BenchmarkRows is benchmark for rows
357
370
func BenchmarkRows (b * testing.B ) {
358
371
db .once .Do (makeBench )
359
372
@@ -378,6 +391,7 @@ func BenchmarkRows(b *testing.B) {
378
391
}
379
392
}
380
393
394
+ // BenchmarkStmtRows is benchmark for statement rows
381
395
func BenchmarkStmtRows (b * testing.B ) {
382
396
db .once .Do (makeBench )
383
397
0 commit comments