2017-03-08 17:17:07 +00:00
|
|
|
package datastore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2021-06-26 04:46:51 +00:00
|
|
|
"github.com/fleetdm/fleet/v4/server/fleet"
|
2017-03-09 18:40:52 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
2017-03-08 17:17:07 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
func testMigrationStatus(t *testing.T, ds fleet.Datastore) {
|
2017-03-08 17:17:07 +00:00
|
|
|
if ds.Name() == "inmem" {
|
|
|
|
t.Skip("inmem is being deprecated, test skipped")
|
|
|
|
}
|
|
|
|
|
|
|
|
require.Nil(t, ds.Drop())
|
2017-03-09 18:40:52 +00:00
|
|
|
|
|
|
|
status, err := ds.MigrationStatus()
|
|
|
|
require.Nil(t, err)
|
2021-06-06 22:07:29 +00:00
|
|
|
assert.EqualValues(t, fleet.NoMigrationsCompleted, status)
|
2017-03-08 17:17:07 +00:00
|
|
|
|
|
|
|
require.Nil(t, ds.MigrateTables())
|
|
|
|
|
2017-03-09 18:40:52 +00:00
|
|
|
status, err = ds.MigrationStatus()
|
|
|
|
require.Nil(t, err)
|
2021-06-06 22:07:29 +00:00
|
|
|
assert.EqualValues(t, fleet.SomeMigrationsCompleted, status)
|
2017-03-09 18:40:52 +00:00
|
|
|
|
2017-03-08 17:17:07 +00:00
|
|
|
require.Nil(t, ds.MigrateData())
|
2017-03-09 18:40:52 +00:00
|
|
|
|
|
|
|
status, err = ds.MigrationStatus()
|
|
|
|
require.Nil(t, err)
|
2021-06-06 22:07:29 +00:00
|
|
|
assert.EqualValues(t, fleet.AllMigrationsCompleted, status)
|
2017-03-08 17:17:07 +00:00
|
|
|
}
|