You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: db_test.go
    path of file: ./repos/dbmate/pkg/dbmate
    
    the code of the file until where you have to start completion: package dbmate_test

import (
	"net/url"
	"os"
	"path/filepath"
	"testing"
	"testing/fstest"
	"time"

	"github.com/amacneil/dbmate/v2/pkg/dbmate"
	"github.com/amacneil/dbmate/v2/pkg/dbutil"
	_ "github.com/amacneil/dbmate/v2/pkg/driver/mysql"
	_ "github.com/amacneil/dbmate/v2/pkg/driver/postgres"
	_ "github.com/amacneil/dbmate/v2/pkg/driver/sqlite"

	"github.com/stretchr/testify/require"
	"github.com/zenizh/go-capturer"
)

var rootDir string

func newTestDB(t *testing.T, u *url.URL) *dbmate.DB {
	var err error

	// find root directory relative to current directory
	if rootDir == "" {
		rootDir, err = filepath.Abs("../..")
		require.NoError(t, err)
	}

	err = os.Chdir(rootDir + "/testdata")
	require.NoError(t, err)

	db := dbmate.New(u)
	db.AutoDumpSchema = false

	return db
}

func TestNew(t *testing.T) {
	db := dbmate.New(dbutil.MustParseURL("foo:test"))
	require.True(t, db.AutoDumpSchema)
	require.Equal(t, "foo:tes
    
func TestLoadSchema(t *testing.T) {
	u := dbutil.MustParseURL(os.Getenv("POSTGRES_TEST_URL"))
	db := newTestDB(t, u)
	drv, err := db.Driver()
	require.NoError(t, err)

	// create custom schema file directory
	dir, err := os.MkdirTemp("", "dbmate")
	require.NoError(t, err)
	defer os.RemoveAll(dir)

	// create schema.sql in subdirectory to test creating directory
	db.SchemaFile = filepath.Join(dir, "/schema/schema.sql")

	// prepare database state
	err = db.Drop()
	require.NoError(t, err)
	err = db.CreateAndMigrate()
	require.NoError(t, err)

	// schema.sql should not exist
	_, err = os.Stat(db.SchemaFile)
	require.True(t, os.IsNotExist(err))

	// load schema should return error
	err = db.LoadSchema()
	require.Error(t, err)
	require.Contains(t, err.Error(), "no such file or directory")

	// create schema file
	err = db.DumpSchema()
	require.NoError(t, err)

	// schema.sql should exist
	_, err = os.Stat(db.SchemaFile)
	require.NoError(t, err)

	// drop and create database
	err = db.Drop()
	require.NoError(t, err)
	err = db.Create()
	require.NoError(t, err)

	// load schema.sql into database
	err = db.LoadSchema()
	require.NoError(t, err)

	// verify result
	sqlDB, err := drv.Open()
	require.NoError(t, err)
	defer dbutil.MustClose(sqlDB)

	// check applied migrations
	appliedMigrations, err := drv.SelectMigrations(sqlDB, -1)
	require.NoError(t, err)
	require.Equal(t, map[string]bool{"20200227231541": true, "20151129054053": true}, appliedMigrations)

	// users and posts tables have been created
	var count int
	err = sqlDB.QueryRow("select count(*) from users").Scan(&count)
	require.NoError(t, err)
	err = sqlDB.QueryRow("select count(*) from posts").Scan(&count)
	require.NoError(t, err)
}