package test

import (
	"database/sql"
	"fmt"
	"testing"
	_ "xugu_go_driver/xugu"
)

var crea = []string{

	"create table gotab3(C1 INT, C2 CLOB, C3 BLOB, C4 BINARY)"}

var db *sql.DB

func init() {
	var err error
	db, err = sql.Open("xugusql", "IP=10.28.20.101;"+
		"DB=GOdb;User=SYSDBA;PWD=SYSDBA;"+
		"Port= 5190;AUTO_COMMIT=on;CHAR_SET=UTF8")
	if err != nil {
		fmt.Printf("[ERROR] %s\n", err.Error())
	}
}

func TestCreateTable(t *testing.T) {

	// db, err := sql.Open("xugusql", "IP=10.28.20.101;"+
	// 	"DB=godb;User=SYSDBA;PWD=SYSDBA;"+
	// 	"Port=5190;AUTO_COMMIT=on;CHAR_SET=UTF8")

	for _, sql := range crea {

		_, err := db.Exec(sql)
		if err != nil {

			fmt.Printf("[ERROR] %s\n", err.Error())
			continue
		}

		fmt.Printf("%s ... ok\n", sql)
	}

	err := db.Close()
	if err != nil {

		fmt.Printf("[ERROR] %s\n", err.Error())
	}
}
