Create Proper Migration tests #15116

Merged
lunny merged 8 commits from migration-tests into master 2021-03-24 18:27:23 +00:00
Contributor

Unfortunately our testing regime has so far meant that migrations do not
get proper testing.

This PR begins the process of creating migration tests for this.

Signed-off-by: Andrew Thornton art27@cantab.net

Unfortunately our testing regime has so far meant that migrations do not get proper testing. This PR begins the process of creating migration tests for this. Signed-off-by: Andrew Thornton <art27@cantab.net>
zeripath reviewed 2021-03-22 22:00:00 +00:00
Author
Contributor
```suggestion ```
zeripath reviewed 2021-03-22 22:04:01 +00:00
Author
Contributor
```suggestion ```
Author
Contributor
		t.Logf("no fixtures found in: %s", fixturesDir)
```suggestion t.Logf("no fixtures found in: %s", fixturesDir) ```
@ -0,0 +195,4 @@
// Provide models to be sync'd with the database - in particular any models you expect fixtures to be loaded from.
//
// fixtures in `models/migrations/fixtures/<TestName>` will be loaded automatically
func prepareTestEnv(t *testing.T, skip int, syncModels ...interface{}) (*xorm.Engine, func()) {
Author
Contributor
// prepareTestEnv prepares the test environment. The skip parameter should usually be 0. Provide models to be sync'd
// with the database - in particular any models you expect fixtures to be loaded from.
//
// fixtures in `models/migrations/fixtures/<TestName>` will be loaded automatically
func prepareTestEnv(t *testing.T, skip int, syncModels ...interface{}) (*xorm.Engine, func()) {
```suggestion // prepareTestEnv prepares the test environment. The skip parameter should usually be 0. Provide models to be sync'd // with the database - in particular any models you expect fixtures to be loaded from. // // fixtures in `models/migrations/fixtures/<TestName>` will be loaded automatically func prepareTestEnv(t *testing.T, skip int, syncModels ...interface{}) (*xorm.Engine, func()) { ```
6543 (Migrated from github.com) approved these changes 2021-03-23 12:19:58 +00:00
kdumontnu (Migrated from github.com) approved these changes 2021-03-24 16:00:39 +00:00
kdumontnu (Migrated from github.com) left a comment

Thanks for adding these! ?

Do you think it would be good practice to add a comment block at the top of v176_test.go and v177_test.go to explain at high level what the migrations intend to do? Ex. "create index X", etc.

Thanks for adding these! ? Do you think it would be good practice to add a comment block at the top of `v176_test.go` and `v177_test.go` to explain at high level what the migrations intend to do? Ex. "create index X", etc.
6543 (Migrated from github.com) approved these changes 2021-03-24 18:26:14 +00:00
This repo is archived. You cannot comment on pull requests.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: lunny/gitea#15116
No description provided.