()
| 43 | } |
| 44 | |
| 45 | func (s *MigrationSuite) TestMigration() { |
| 46 | db, err := New("sqlite3", s.tmpDir.Path("test_obsolete.db"), "admin", "admin", 6, true) |
| 47 | assert.Nil(s.T(), err) |
| 48 | defer db.Close() |
| 49 | |
| 50 | assert.True(s.T(), db.DB.Migrator().HasTable(new(model.Application))) |
| 51 | |
| 52 | // a user already exist, not adding a new user |
| 53 | if user, err := db.GetUserByName("admin"); assert.NoError(s.T(), err) { |
| 54 | assert.Nil(s.T(), user) |
| 55 | } |
| 56 | |
| 57 | // the old user should persist |
| 58 | if user, err := db.GetUserByName("test_user"); assert.NoError(s.T(), err) { |
| 59 | assert.Equal(s.T(), true, user.Admin) |
| 60 | } |
| 61 | |
| 62 | // we should be able to create applications |
| 63 | if user, err := db.GetUserByName("test_user"); assert.NoError(s.T(), err) { |
| 64 | assert.Nil(s.T(), db.CreateApplication(&model.Application{ |
| 65 | Token: "A1234", |
| 66 | UserID: user.ID, |
| 67 | Description: "this is a test application", |
| 68 | Name: "test application", |
| 69 | })) |
| 70 | } |
| 71 | if app, err := db.GetApplicationByToken("A1234"); assert.NoError(s.T(), err) { |
| 72 | assert.Equal(s.T(), "test application", app.Name) |
| 73 | } |
| 74 | } |
nothing calls this directly
no test coverage detected