github.com/ncruces/go-sqlite3@v0.15.1-0.20240520133447-53eef1510ff0/vfs/registry_test.go (about) 1 package vfs_test 2 3 import ( 4 "testing" 5 6 "github.com/ncruces/go-sqlite3" 7 _ "github.com/ncruces/go-sqlite3/embed" 8 "github.com/ncruces/go-sqlite3/vfs" 9 ) 10 11 type testVFS struct { 12 *testing.T 13 } 14 15 func (t testVFS) Open(name string, flags vfs.OpenFlag) (vfs.File, vfs.OpenFlag, error) { 16 t.Log("Open", name, flags) 17 t.SkipNow() 18 return nil, flags, nil 19 } 20 21 func (t testVFS) Delete(name string, syncDir bool) error { 22 t.Log("Delete", name, syncDir) 23 return nil 24 } 25 26 func (t testVFS) Access(name string, flags vfs.AccessFlag) (bool, error) { 27 t.Log("Access", name, flags) 28 return true, nil 29 } 30 31 func (t testVFS) FullPathname(name string) (string, error) { 32 t.Log("FullPathname", name) 33 return name, nil 34 } 35 36 func TestRegister(t *testing.T) { 37 vfs.Register("foo", testVFS{t}) 38 defer vfs.Unregister("foo") 39 40 conn, err := sqlite3.Open("file:file.db?vfs=foo") 41 if err != nil { 42 t.Fatal(err) 43 } 44 defer conn.Close() 45 46 t.Error("want skip") 47 }