MCPcopy Index your code
hub / github.com/riverqueue/river / buildTestMigrationsBundle

Function buildTestMigrationsBundle

rivermigrate/river_migrate_test.go:982–1014  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

980}
981
982func buildTestMigrationsBundle(t *testing.T) *testMigrationsBundle {
983 t.Helper()
984
985 // `migration/` subdir is added by migrationsFromFS
986 migrationFS := os.DirFS("../riverdriver/riverpgxv5")
987
988 migrations, err := migrationsFromFS(migrationFS, riverdriver.MigrationLineMain)
989 require.NoError(t, err)
990
991 // We base our test migrations on the actual line of migrations, so get
992 // their maximum version number which we'll use to define test version
993 // numbers so that the tests don't break anytime we add a new one.
994 migrationsMaxVersion := migrations[len(migrations)-1].Version
995
996 testVersions := []Migration{
997 {
998 Version: migrationsMaxVersion + 1,
999 SQLUp: "CREATE TABLE /* TEMPLATE: schema */test_table(id bigserial PRIMARY KEY);",
1000 SQLDown: "DROP TABLE /* TEMPLATE: schema */test_table;",
1001 },
1002 {
1003 Version: migrationsMaxVersion + 2,
1004 SQLUp: "ALTER TABLE /* TEMPLATE: schema */test_table ADD COLUMN name varchar(200); CREATE INDEX idx_test_table_name ON /* TEMPLATE: schema */test_table(name);",
1005 SQLDown: "DROP INDEX /* TEMPLATE: schema */idx_test_table_name; ALTER TABLE /* TEMPLATE: schema */test_table DROP COLUMN name;",
1006 },
1007 }
1008
1009 return &testMigrationsBundle{
1010 MaxVersion: migrationsMaxVersion,
1011 WithTestVersionsMap: validateAndInit(append(migrations, testVersions...)),
1012 WithTestVersionsMaxVersion: migrationsMaxVersion + len(testVersions),
1013 }
1014}
1015
1016// A command returning an error aborts the transaction. This is a shortcut to
1017// execute a command in a subtransaction so that we can verify an error, but

Callers 1

TestMigratorFunction · 0.85

Calls 3

migrationsFromFSFunction · 0.85
validateAndInitFunction · 0.85
HelperMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…