Example #1
0
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"))
}
Example #2
0
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"))
}