pgsql: Add test for migrations

This commit is contained in:
Sida Chen 2019-03-06 16:33:42 -05:00
parent ea418cffd4
commit 497b79a293

View File

@ -12,22 +12,22 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package pgsql package migrations_test
import ( import (
"testing" "testing"
"github.com/coreos/clair/database/pgsql/migrations"
"github.com/coreos/clair/database/pgsql/testutil"
_ "github.com/lib/pq" _ "github.com/lib/pq"
"github.com/remind101/migrate" "github.com/remind101/migrate"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/coreos/clair/database/pgsql/migrations"
) )
var userTableCount = `SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname='public'` var userTableCount = `SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname='public'`
func TestMigration(t *testing.T) { func TestMigration(t *testing.T) {
db, cleanup := createAndConnectTestDB(t, "TestMigration") db, cleanup := testutil.CreateAndConnectTestDB(t, "TestMigration")
defer cleanup() defer cleanup()
err := migrate.NewPostgresMigrator(db).Exec(migrate.Up, migrations.Migrations...) err := migrate.NewPostgresMigrator(db).Exec(migrate.Up, migrations.Migrations...)