Skip to content

Commit

Permalink
Ensure database is migrated to the current version before testing
Browse files Browse the repository at this point in the history
  • Loading branch information
bastjan committed Jan 18, 2022
1 parent 1d3bfe4 commit 9e4c0db
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pkg/db/migrations_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package db_test

import (
"testing"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"

"github.com/appuio/appuio-cloud-reporting/pkg/db"
"github.com/appuio/appuio-cloud-reporting/pkg/db/dbtest"
)

type MigrationTestSuite struct {
dbtest.Suite
}

func (s *MigrationTestSuite) TestMigrations_DatabaseShouldBeFullyMigrated() {
t := s.T()
pending, err := db.Pending(s.DB().DB)
require.NoError(t, err)
require.Lenf(t, pending, 0, "the test database should be migrated to the newest version before running tests")
}

func TestMigrations(t *testing.T) {
suite.Run(t, new(MigrationTestSuite))
}

0 comments on commit 9e4c0db

Please sign in to comment.