Merge branch 'master' into interpolate-params

This commit is contained in:
Shlomi Noach 2017-07-26 10:01:41 +03:00 committed by GitHub
commit d6f1675f1b

View File

@ -18,25 +18,28 @@ func init() {
} }
func TestGetTableNames(t *testing.T) { func TestGetTableNames(t *testing.T) {
context = newMigrationContext()
{ {
context = newMigrationContext()
context.OriginalTableName = "some_table" context.OriginalTableName = "some_table"
test.S(t).ExpectEquals(context.GetOldTableName(), "_some_table_del") test.S(t).ExpectEquals(context.GetOldTableName(), "_some_table_del")
test.S(t).ExpectEquals(context.GetGhostTableName(), "_some_table_gho") test.S(t).ExpectEquals(context.GetGhostTableName(), "_some_table_gho")
test.S(t).ExpectEquals(context.GetChangelogTableName(), "_some_table_ghc") test.S(t).ExpectEquals(context.GetChangelogTableName(), "_some_table_ghc")
} }
{ {
context = newMigrationContext()
context.OriginalTableName = "a123456789012345678901234567890123456789012345678901234567890" context.OriginalTableName = "a123456789012345678901234567890123456789012345678901234567890"
test.S(t).ExpectEquals(context.GetOldTableName(), "_a1234567890123456789012345678901234567890123456789012345678_del") test.S(t).ExpectEquals(context.GetOldTableName(), "_a1234567890123456789012345678901234567890123456789012345678_del")
test.S(t).ExpectEquals(context.GetGhostTableName(), "_a1234567890123456789012345678901234567890123456789012345678_gho") test.S(t).ExpectEquals(context.GetGhostTableName(), "_a1234567890123456789012345678901234567890123456789012345678_gho")
test.S(t).ExpectEquals(context.GetChangelogTableName(), "_a1234567890123456789012345678901234567890123456789012345678_ghc") test.S(t).ExpectEquals(context.GetChangelogTableName(), "_a1234567890123456789012345678901234567890123456789012345678_ghc")
} }
{ {
context = newMigrationContext()
context.OriginalTableName = "a123456789012345678901234567890123456789012345678901234567890123" context.OriginalTableName = "a123456789012345678901234567890123456789012345678901234567890123"
oldTableName := context.GetOldTableName() oldTableName := context.GetOldTableName()
test.S(t).ExpectEquals(oldTableName, "_a1234567890123456789012345678901234567890123456789012345678_del") test.S(t).ExpectEquals(oldTableName, "_a1234567890123456789012345678901234567890123456789012345678_del")
} }
{ {
context = newMigrationContext()
context.OriginalTableName = "a123456789012345678901234567890123456789012345678901234567890123" context.OriginalTableName = "a123456789012345678901234567890123456789012345678901234567890123"
context.TimestampOldTable = true context.TimestampOldTable = true
longForm := "Jan 2, 2006 at 3:04pm (MST)" longForm := "Jan 2, 2006 at 3:04pm (MST)"
@ -45,9 +48,9 @@ func TestGetTableNames(t *testing.T) {
test.S(t).ExpectEquals(oldTableName, "_a1234567890123456789012345678901234567890123_20130203195400_del") test.S(t).ExpectEquals(oldTableName, "_a1234567890123456789012345678901234567890123_20130203195400_del")
} }
{ {
context = newMigrationContext()
context.OriginalTableName = "foo_bar_baz" context.OriginalTableName = "foo_bar_baz"
context.ForceTmpTableName = "tmp" context.ForceTmpTableName = "tmp"
context.TimestampOldTable = false
test.S(t).ExpectEquals(context.GetOldTableName(), "_tmp_del") test.S(t).ExpectEquals(context.GetOldTableName(), "_tmp_del")
test.S(t).ExpectEquals(context.GetGhostTableName(), "_tmp_gho") test.S(t).ExpectEquals(context.GetGhostTableName(), "_tmp_gho")
test.S(t).ExpectEquals(context.GetChangelogTableName(), "_tmp_ghc") test.S(t).ExpectEquals(context.GetChangelogTableName(), "_tmp_ghc")