func downgradeDB(t *testing.T, vdb *database.VersionedDB) { // downgrade to 0 err := vdb.Migrate(0) assert.Nil(t, err) dbVersion, err := vdb.DBVersion() assert.Nil(t, err) assert.Equal(t, 0, dbVersion) }
// Test wether the migration steps execute correctly. func testDBVersioning(t *testing.T, vdb *database.VersionedDB) { // get the DB version dbVersion, err := vdb.DBVersion() assert.Nil(t, err) maxVersion := vdb.MaxDBVersion() downgradeDB(t, vdb) // upgrade the the latest version err = vdb.Migrate(maxVersion) assert.Nil(t, err) dbVersion, err = vdb.DBVersion() assert.Nil(t, err) assert.Equal(t, maxVersion, dbVersion) }