Пример #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"))
}
Пример #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"))
}
Пример #3
0
func TestSyncTableBad(t *testing.T) {
	setTest()
	kmgSql.MustSyncTable(testBadTableConfig)
	Ok(kmgSql.MustIsTableExist("testTable"))
}
Пример #4
0
func TestIsTableExist(t *testing.T) {
	setTest()
	Ok(!kmgSql.MustIsTableExist("testTable"))
}