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

     1  package test
     2  
     3  import (
     4  	"database/sql"
     5  	"github.com/team-ide/go-dialect/dialect"
     6  	"github.com/team-ide/go-driver/db_postgresql"
     7  	"testing"
     8  )
     9  
    10  var (
    11  	PostgresqlDb      *sql.DB
    12  	PostgresqlDialect dialect.Dialect
    13  )
    14  
    15  func initPostgresql() {
    16  	if PostgresqlDb != nil {
    17  		return
    18  	}
    19  	var err error
    20  	PostgresqlDb, err = db_postgresql.Open(db_postgresql.GetDSN("postgres", "123456", "127.0.0.1", 5432, "postgres"))
    21  	if err != nil {
    22  		panic(err)
    23  	}
    24  	PostgresqlDialect, err = dialect.NewDialect(dialect.TypePostgresql.Name)
    25  	if err != nil {
    26  		panic(err)
    27  	}
    28  	return
    29  }
    30  
    31  func TestPostgresqlLoad(t *testing.T) {
    32  	initPostgresql()
    33  	owners(PostgresqlDb, PostgresqlDialect)
    34  }
    35  
    36  func TestPostgresqlDDL(t *testing.T) {
    37  	initPostgresql()
    38  	//testTableDelete(PostgresqlDb, dialect.Postgresql, param, "", getTable().Name)
    39  	testDLL(PostgresqlDb, PostgresqlDialect, "")
    40  }
    41  
    42  func TestPostgresqlSql(t *testing.T) {
    43  	initPostgresql()
    44  	sqlInfo := loadSql("temp/sql_kinbase.sql")
    45  	testSql(PostgresqlDb, PostgresqlDialect, "ROOT", sqlInfo)
    46  }