forked from mirror/go-sqlcipher
implement go18 Pinger
This commit is contained in:
parent
86681de00a
commit
6796d46c3a
|
@ -0,0 +1,14 @@
|
|||
package sqlite3
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// Ping implement Pinger.
|
||||
func (c *SQLiteConn) Ping(ctx context.Context) error {
|
||||
if c.db == nil {
|
||||
return errors.New("Connection was closed")
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -1315,6 +1315,22 @@ func TestDeclTypes(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPinger(t *testing.T) {
|
||||
db, err := sql.Open("sqlite3", ":memory:")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = db.Ping()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
db.Close()
|
||||
err = db.Ping()
|
||||
if err == nil {
|
||||
t.Fatal("Should be closed")
|
||||
}
|
||||
}
|
||||
|
||||
var customFunctionOnce sync.Once
|
||||
|
||||
func BenchmarkCustomFunctions(b *testing.B) {
|
||||
|
|
Loading…
Reference in New Issue