fleet/server/datastore/mysql/migrations_test.go
Tomas Touceda a6cff7ea89
Migrate all mysql tests to the new form (#1408)
* Migrate all mysql tests to the new form

* Only dump sql if MYSQL_TEST is on

* Removing parallel until we get rid of this code

* Move TestMain to an actual _test file

* A little experiment with tmpfs to speed up the db

* Let's make sure the dump.sql file is also in ram
2021-07-19 18:20:31 -03:00

37 lines
786 B
Go

package mysql
import (
"testing"
"github.com/fleetdm/fleet/v4/server/fleet"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestMigrationStatus(t *testing.T) {
ds := CreateMySQLDS(t)
defer ds.Close()
if ds.Name() == "inmem" {
t.Skip("inmem is being deprecated, test skipped")
}
require.Nil(t, ds.Drop())
status, err := ds.MigrationStatus()
require.Nil(t, err)
assert.EqualValues(t, fleet.NoMigrationsCompleted, status)
require.Nil(t, ds.MigrateTables())
status, err = ds.MigrationStatus()
require.Nil(t, err)
assert.EqualValues(t, fleet.SomeMigrationsCompleted, status)
require.Nil(t, ds.MigrateData())
status, err = ds.MigrationStatus()
require.Nil(t, err)
assert.EqualValues(t, fleet.AllMigrationsCompleted, status)
}