mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-12 05:59:14 +00:00
Tests.
This commit is contained in:
15
tests/compile/empty/compile_test.go
Normal file
15
tests/compile/empty/compile_test.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package compile_empty
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/ncruces/go-sqlite3"
|
||||
)
|
||||
|
||||
func TestCompile_empty(t *testing.T) {
|
||||
sqlite3.Binary = []byte("\x00asm\x01\x00\x00\x00")
|
||||
_, err := sqlite3.Open(":memory:")
|
||||
if err == nil {
|
||||
t.Error("want error")
|
||||
}
|
||||
}
|
||||
15
tests/compile/missing/compile_test.go
Normal file
15
tests/compile/missing/compile_test.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package compile_empty
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/ncruces/go-sqlite3"
|
||||
)
|
||||
|
||||
func TestCompile_empty(t *testing.T) {
|
||||
sqlite3.Path = "sqlite3.wasm"
|
||||
_, err := sqlite3.Open(":memory:")
|
||||
if err == nil {
|
||||
t.Error("want error")
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,12 @@ func TestDir(t *testing.T) {
|
||||
}
|
||||
var serr *sqlite3.Error
|
||||
if !errors.As(err, &serr) {
|
||||
t.Fatal("want sqlite3.Error")
|
||||
t.Fatalf("got %T, want sqlite3.Error", err)
|
||||
}
|
||||
if serr.Code() != sqlite3.CANTOPEN {
|
||||
t.Error("want sqlite3.CANTOPEN")
|
||||
if rc := serr.Code(); rc != sqlite3.CANTOPEN {
|
||||
t.Errorf("got %d, want sqlite3.CANTOPEN", rc)
|
||||
}
|
||||
if got := err.Error(); got != "sqlite3: unable to open database file" {
|
||||
if got := err.Error(); got != `sqlite3: unable to open database file` {
|
||||
t.Error("got message: ", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user