| 21 | } |
| 22 | |
| 23 | func (s *MigrationSuite) BeforeTest(suiteName, testName string) { |
| 24 | s.tmpDir = test.NewTmpDir("gotify_migrationsuite") |
| 25 | db, err := gorm.Open(sqlite.Open(s.tmpDir.Path("test_obsolete.db")), &gorm.Config{}) |
| 26 | assert.NoError(s.T(), err) |
| 27 | sqlDB, err := db.DB() |
| 28 | assert.NoError(s.T(), err) |
| 29 | defer sqlDB.Close() |
| 30 | |
| 31 | assert.Nil(s.T(), db.Migrator().CreateTable(new(model.User))) |
| 32 | assert.Nil(s.T(), db.Create(&model.User{ |
| 33 | Name: "test_user", |
| 34 | Admin: true, |
| 35 | }).Error) |
| 36 | |
| 37 | // we should not be able to create applications by now |
| 38 | assert.False(s.T(), db.Migrator().HasTable(new(model.Application))) |
| 39 | } |
| 40 | |
| 41 | func (s *MigrationSuite) AfterTest(suiteName, testName string) { |
| 42 | assert.Nil(s.T(), s.tmpDir.Clean()) |