<commit_before>package migratest

import (
	"context"
	"fmt"
	"testing"

	"github.com/spf13/pflag"

	"github.com/ory/hydra/persistence/sql"

	"github.com/ory/x/logrusx"
	"github.com/ory/x/popx"

	"github.com/ory/x/sqlcon/dockertest"

	"github.com/ory/hydra/driver/config"

	"github.com/gobuffalo/pop/v5"
	"github.com/jmoiron/sqlx"
	"github.com/stretchr/testify/require"

	"github.com/ory/x/dbal"

	"github.com/ory/hydra/client"
	"github.com/ory/hydra/consent"
	"github.com/ory/hydra/driver"
	"github.com/ory/hydra/jwk"
	"github.com/ory/hydra/oauth2"
	"github.com/ory/hydra/x"
)

func TestMigrations(t *testing.T) {
	if testing.Short() {
		t.SkipNow()
		return
	}

	connections := make(map[string]*pop.Connection, 3)
	dockertest.Parallel([]func(){
		func() {
			connections["postgres"] = dockertest.ConnectToTestPostgreSQLPop(t)
		},
		func() {
			connections["mysql"] = dockertest.ConnectToTestMySQLPop(t)
		},
		func() {
			connections["cockroach"] = dockertest.ConnectToTestCockroachDBPop(t)
		},
	})

	for db, c := range connections {
		t.Run(fmt.Sprintf("database=%s", db), func(t *testing.T) {
			x.CleanSQLPop(t, c)
			url := c.URL()

			// workaround for https://github.com/gobuffalo/pop/issues/538
			if db == "mysql" {
				url = "mysql://" + url
			}

			d := driver.New(pflag.NewFlagSet("", pflag.ContinueOnError), driver.ForceConfigValue(config.KeyDSN, url))
			var dbx *sqlx.DB
			require.NoError(t,
				dbal.Connect(url, logrusx.New("", ""), func() error {
					return nil<commit_msg>test: skip preloading in migration tests<commit_after>package migratest

import (
	"context"
	"fmt"
	"testing"

	"github.com/spf13/pflag"

	"github.com/ory/hydra/persistence/sql"

	"github.com/ory/x/logrusx"
	"github.com/ory/x/popx"

	"github.com/ory/x/sqlcon/dockertest"

	"github.com/ory/hydra/driver/config"

	"github.com/gobuffalo/pop/v5"
	"github.com/jmoiron/sqlx"
	"github.com/stretchr/testify/require"

	"github.com/ory/x/dbal"

	"github.com/ory/hydra/client"
	"github.com/ory/hydra/consent"
	"github.com/ory/hydra/driver"
	"github.com/ory/hydra/jwk"
	"github.com/ory/hydra/oauth2"
	"github.com/ory/hydra/x"
)

func TestMigrations(t *testing.T) {
	if testing.Short() {
		t.SkipNow()
		return
	}

	connections := make(map[string]*pop.Connection, 3)
	dockertest.Parallel([]func(){
		func() {
			connections["postgres"] = dockertest.ConnectToTestPostgreSQLPop(t)
		},
		func() {
			connections["mysql"] = dockertest.ConnectToTestMySQLPop(t)
		},
		func() {
			connections["cockroach"] = dockertest.ConnectToTestCockroachDBPop(t)
		},
	})

	for db, c := range connections {
		t.Run(fmt.Sprintf("database=%s", db), func(t *testing.T) {
			x.CleanSQLPop(t, c)
			url := c.URL()

			// workaround for https://github.com/gobuffalo/pop/issues/538
			if db == "mysql" {
				url = "mysql://" + url
			}

			d := driver.New(
				pflag.NewFlagSet("", pflag.ContinueOnError),
				driver.ForceConfigValue(config.KeyDSN, url),
				driver.DisablePreloading(),
				driver.DisableValidation(),
			)
			var dbx *sqlx.DB
			require.NoError(t,
				dbal.Connect(url, logrusx.New("", ""), func() error {
					return nil
{'fraction_non_alphanumeric': 0.17618586640851888, 'fraction_numerical': 0.005162955792191029, 'mean_word_length': 3.7913446676970635, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2547803', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1258, 'n_words': 165}