(t *testing.T)
| 980 | } |
| 981 | |
| 982 | func 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 |
no test coverage detected
searching dependent graphs…