aboutsummaryrefslogtreecommitdiff
path: root/sqlite3_go18_test.go
diff options
context:
space:
mode:
authorYasuhiro Matsumoto <mattn.jp@gmail.com>2017-09-28 12:04:07 +0900
committerYasuhiro Matsumoto <mattn.jp@gmail.com>2017-09-28 12:04:07 +0900
commit68bcba68d90f47673ebcb643bdc1968868fae121 (patch)
tree7e4ddb84fec1e2b5941c1857c69e5dcaef87e839 /sqlite3_go18_test.go
parentMerge pull request #423 from danderson/master (diff)
downloadgolite-68bcba68d90f47673ebcb643bdc1968868fae121.tar.gz
golite-68bcba68d90f47673ebcb643bdc1968868fae121.tar.xz
use file instead of memory for TestShortTimeout
Diffstat (limited to 'sqlite3_go18_test.go')
-rw-r--r--sqlite3_go18_test.go23
1 files changed, 9 insertions, 14 deletions
diff --git a/sqlite3_go18_test.go b/sqlite3_go18_test.go
index a5f4aae..cca0a1f 100644
--- a/sqlite3_go18_test.go
+++ b/sqlite3_go18_test.go
@@ -111,14 +111,17 @@ func initDatabase(t *testing.T, db *sql.DB, rowCount int64) {
}
func TestShortTimeout(t *testing.T) {
- db, err := sql.Open("sqlite3", "file::memory:?mode=memory&cache=shared")
+ srcTempFilename := TempFilename(t)
+ defer os.Remove(srcTempFilename)
+
+ db, err := sql.Open("sqlite3", srcTempFilename)
if err != nil {
t.Fatal(err)
}
defer db.Close()
- initDatabase(t, db, 10000)
+ initDatabase(t, db, 100)
- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Microsecond)
+ ctx, cancel := context.WithTimeout(context.Background(), 1*time.Microsecond)
defer cancel()
query := `SELECT key1, key_id, key2, key3, key4, key5, key6, data
FROM test_table
@@ -127,16 +130,8 @@ func TestShortTimeout(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- defer rows.Close()
- for rows.Next() {
- var key1, keyid, key2, key3, key4, key5, key6 string
- var data []byte
- err = rows.Scan(&key1, &keyid, &key2, &key3, &key4, &key5, &key6, &data)
- if err != nil {
- break
- }
- }
- if context.DeadlineExceeded != ctx.Err() {
- t.Fatal(ctx.Err())
+ if ctx.Err() != nil && context.DeadlineExceeded != ctx.Err() {
+ t.Fatalf("%v", ctx.Err())
}
+ rows.Close()
}