Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

Fixed migration test numbering and func order. #2250

Merged
merged 1 commit into from
Aug 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 27 additions & 26 deletions migration/migration_blackbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ func TestMigrations(t *testing.T) {
t.Run("TestMigration97", testMigration97RemoveResolutionFieldFromImpediment)
t.Run("TestMigration98", testMigration98Boards)
t.Run("TestMigration99", testMigration99CodebaseCVEScanDefaultFalse)
t.Run("TestMigration100", testDropUserspacedataTable)
t.Run("TestMigration101", testTypeGroupHasDescriptionField)
t.Run("TestMigration102", testLinkTypeDescriptionFields)
t.Run("TestMigration100", testMigration100DropUserspacedataTable)
t.Run("TestMigration101", testMigration101TypeGroupHasDescriptionField)
t.Run("TestMigration102", testMigration102LinkTypeDescriptionFields)
t.Run("TestMigration103", testMigration103NotNullNotEmptyonEmail)

// Perform the migration
Expand Down Expand Up @@ -1182,6 +1182,30 @@ func testMigration99CodebaseCVEScanDefaultFalse(t *testing.T) {
require.Nil(t, runSQLscript(sqlDB, "099-codebase-cve-scan-default-false-cleanup.sql"))
}

// testMigration100DropUserspacedataTable tests that the userspace_data
// table no longer exists - previously used as a temporary solution to
// get data from tenant jenkins
func testMigration100DropUserspacedataTable(t *testing.T) {
migrateToVersion(t, sqlDB, migrations[:101], 101)
require.False(t, dialect.HasTable("userspace_data"))
}

// testMigration101TypeGroupHasDescriptionField checks that the work item type groups table
// has a description after updating to DB version 101.
func testMigration101TypeGroupHasDescriptionField(t *testing.T) {
migrateToVersion(t, sqlDB, migrations[:102], 102)
require.True(t, dialect.HasColumn("work_item_type_groups", "description"))
}

// testMigration102LinkTypeDescriptionFields checks that the work item link types table has
// a forward_description and a reverse_description after updating to DB version
// 102.
func testMigration102LinkTypeDescriptionFields(t *testing.T) {
migrateToVersion(t, sqlDB, migrations[:103], 103)
require.True(t, dialect.HasColumn("work_item_link_types", "forward_description"))
require.True(t, dialect.HasColumn("work_item_link_types", "reverse_description"))
}

func testMigration103NotNullNotEmptyonEmail(t *testing.T) {
migrateToVersion(t, sqlDB, migrations[:103], 103)

Expand Down Expand Up @@ -1251,29 +1275,6 @@ func executeSQLTestFile(filename string, args ...string) fn {
}
}

// test that the userspace_data table no longer exists - previously
// used as a temporary solution to get data from tenant jenkins
func testDropUserspacedataTable(t *testing.T) {
migrateToVersion(t, sqlDB, migrations[:101], 101)
require.False(t, dialect.HasTable("userspace_data"))
}

// testTypeGroupHasDescriptionField checks that the work item type groups table
// has a description after updating to DB version 101.
func testTypeGroupHasDescriptionField(t *testing.T) {
migrateToVersion(t, sqlDB, migrations[:102], 102)
require.True(t, dialect.HasColumn("work_item_type_groups", "description"))
}

// testLinkTypeDescriptionFields checks that the work item link types table has
// a forward_description and a reverse_description after updating to DB version
// 102.
func testLinkTypeDescriptionFields(t *testing.T) {
migrateToVersion(t, sqlDB, migrations[:103], 103)
require.True(t, dialect.HasColumn("work_item_link_types", "forward_description"))
require.True(t, dialect.HasColumn("work_item_link_types", "reverse_description"))
}

// migrateToVersion runs the migration of all the scripts to a certain version
func migrateToVersion(t *testing.T, db *sql.DB, m migration.Migrations, version int64) {
var err error
Expand Down