github.com/ncruces/go-sqlite3@v0.15.1-0.20240520133447-53eef1510ff0/vfs/memdb/memdb_test.go (about)

     1  package memdb
     2  
     3  import (
     4  	"testing"
     5  
     6  	_ "embed"
     7  
     8  	"github.com/ncruces/go-sqlite3"
     9  	_ "github.com/ncruces/go-sqlite3/embed"
    10  	_ "github.com/ncruces/go-sqlite3/tests/testcfg"
    11  )
    12  
    13  //go:embed testdata/wal.db
    14  var walDB []byte
    15  
    16  func Test_wal(t *testing.T) {
    17  	Create("test.db", walDB)
    18  
    19  	db, err := sqlite3.Open("file:/test.db?vfs=memdb")
    20  	if err != nil {
    21  		t.Fatal(err)
    22  	}
    23  	defer db.Close()
    24  
    25  	err = db.Exec(`CREATE TABLE users (id INT, name VARCHAR(10))`)
    26  	if err != nil {
    27  		t.Fatal(err)
    28  	}
    29  }