github.com/team-ide/go-dialect@v1.9.20/test/sqlite_test.go (about)

     1  package test
     2  
     3  import (
     4  	"context"
     5  	"database/sql"
     6  	"github.com/team-ide/go-dialect/dialect"
     7  	"github.com/team-ide/go-driver/db_sqlite3"
     8  	"testing"
     9  )
    10  
    11  var (
    12  	SqliteDb      *sql.DB
    13  	SqliteDialect dialect.Dialect
    14  )
    15  
    16  func initSqlite() (dbContext context.Context) {
    17  	if SqliteDb != nil {
    18  		return
    19  	}
    20  	dsn := db_sqlite3.GetDSN("temp/test_sqlite")
    21  	var err error
    22  	SqliteDb, err = db_sqlite3.Open(dsn)
    23  	if err != nil {
    24  		panic(err)
    25  	}
    26  	SqliteDialect, err = dialect.NewDialect(dialect.TypeSqlite.Name)
    27  	if err != nil {
    28  		panic(err)
    29  	}
    30  	return
    31  }
    32  
    33  func TestSqliteLoad(t *testing.T) {
    34  	initSqlite()
    35  	owners(SqliteDb, SqliteDialect)
    36  }
    37  
    38  func TestSqliteDDL(t *testing.T) {
    39  	initSqlite()
    40  	testDLL(SqliteDb, SqliteDialect, "")
    41  }
    42  
    43  func TestSqliteSql(t *testing.T) {
    44  	initSqlite()
    45  	sqlInfo := loadSql("temp/sql_sqlite.sql")
    46  	testSql(SqliteDb, SqliteDialect, "SYSDBA", sqlInfo)
    47  }