2023-02-07 03:11:59 +00:00
|
|
|
package tests
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"errors"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/ncruces/go-sqlite3"
|
2023-02-08 00:00:53 +00:00
|
|
|
_ "github.com/ncruces/go-sqlite3/embed"
|
2023-02-07 03:11:59 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestDir(t *testing.T) {
|
|
|
|
|
_, err := sqlite3.Open(".")
|
|
|
|
|
if err == nil {
|
|
|
|
|
t.Fatal("want error")
|
|
|
|
|
}
|
|
|
|
|
var serr *sqlite3.Error
|
|
|
|
|
if !errors.As(err, &serr) {
|
2023-02-10 16:42:49 +00:00
|
|
|
t.Fatalf("got %T, want sqlite3.Error", err)
|
2023-02-07 03:11:59 +00:00
|
|
|
}
|
2023-02-10 16:42:49 +00:00
|
|
|
if rc := serr.Code(); rc != sqlite3.CANTOPEN {
|
|
|
|
|
t.Errorf("got %d, want sqlite3.CANTOPEN", rc)
|
2023-02-07 03:11:59 +00:00
|
|
|
}
|
2023-02-10 16:42:49 +00:00
|
|
|
if got := err.Error(); got != `sqlite3: unable to open database file` {
|
2023-02-07 03:11:59 +00:00
|
|
|
t.Error("got message: ", got)
|
|
|
|
|
}
|
|
|
|
|
}
|