func TestCreateTable(t *testing.T) { setTest() kmgSql.MustCreateTable(testTableConfig) ret := kmgSql.MustQueryOne("SHOW CREATE TABLE testTable") Ok(strings.Contains(fmt.Sprint(ret), "Id")) Ok(strings.Contains(fmt.Sprint(ret), "Name")) Ok(kmgSql.MustIsTableExist("testTable")) }
func TestModifyTable(t *testing.T) { setTest() kmgSql.MustCreateTable(testTableConfig) newTestTableConfig := kmgSql.Table{ Name: "testTable", FieldList: map[string]kmgSql.DbType{ "Id": kmgSql.DbTypeInt, "Name": kmgSql.DbTypeLongString, "Age": kmgSql.DbTypeInt, }, PrimaryKey: "Id", UniqueKey: [][]string{ []string{"Id", "Name"}, }, Null: []string{"Name"}, } kmgSql.MustModifyTable(newTestTableConfig) ret := kmgSql.MustQueryOne("SHOW CREATE TABLE testTable") Ok(strings.Contains(fmt.Sprint(ret), "Id")) Ok(strings.Contains(fmt.Sprint(ret), "Name")) Ok(strings.Contains(fmt.Sprint(ret), "Age")) Ok(kmgSql.MustIsTableExist("testTable")) }
func TestSyncTableBad(t *testing.T) { setTest() kmgSql.MustSyncTable(testBadTableConfig) Ok(kmgSql.MustIsTableExist("testTable")) }
func TestIsTableExist(t *testing.T) { setTest() Ok(!kmgSql.MustIsTableExist("testTable")) }