MCPcopy
hub / github.com/gotify/server / TestMigration

Method TestMigration

database/migration_test.go:45–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

43}
44
45func (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}

Callers

nothing calls this directly

Calls 6

PathMethod · 0.80
NewFunction · 0.70
GetUserByNameMethod · 0.65
CreateApplicationMethod · 0.65
GetApplicationByTokenMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected