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

Method BeforeTest

database/migration_test.go:23–39  ·  view source on GitHub ↗
(suiteName, testName string)

Source from the content-addressed store, hash-verified

21}
22
23func (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
41func (s *MigrationSuite) AfterTest(suiteName, testName string) {
42 assert.Nil(s.T(), s.tmpDir.Clean())

Callers

nothing calls this directly

Calls 4

NewTmpDirFunction · 0.92
OpenMethod · 0.80
PathMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected