From a58b0be362a3f76189372facfa7425f41d9031e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A5=BA=E5=AD=90w=20=28Yumechi=29?= Date: Fri, 20 Sep 2024 05:00:17 -0500 Subject: [PATCH 1/2] bug: fixed a race condition in database test (#690) * bug: fixed a race condition in database test and plugin integration test Signed-off-by: eternal-flame-AD --------- Signed-off-by: eternal-flame-AD --- test/testdb/database.go | 4 ++-- ui/src/tests/setup.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/testdb/database.go b/test/testdb/database.go index e12d0122..29f8cfdd 100644 --- a/test/testdb/database.go +++ b/test/testdb/database.go @@ -30,7 +30,7 @@ type MessageBuilder struct { // NewDBWithDefaultUser creates a new test db instance with the default user. func NewDBWithDefaultUser(t *testing.T) *Database { - db, err := database.New("sqlite3", fmt.Sprintf("file:%s?mode=memory&cache=shared", fmt.Sprint(time.Now().Unix())), "admin", "pw", 5, true) + db, err := database.New("sqlite3", fmt.Sprintf("file:%s?mode=memory&cache=shared", fmt.Sprint(time.Now().UnixNano())), "admin", "pw", 5, true) assert.Nil(t, err) assert.NotNil(t, db) return &Database{GormDatabase: db, t: t} @@ -38,7 +38,7 @@ func NewDBWithDefaultUser(t *testing.T) *Database { // NewDB creates a new test db instance. func NewDB(t *testing.T) *Database { - db, err := database.New("sqlite3", fmt.Sprintf("file:%s?mode=memory&cache=shared", fmt.Sprint(time.Now().Unix())), "admin", "pw", 5, false) + db, err := database.New("sqlite3", fmt.Sprintf("file:%s?mode=memory&cache=shared", fmt.Sprint(time.Now().UnixNano())), "admin", "pw", 5, false) assert.Nil(t, err) assert.NotNil(t, db) return &Database{GormDatabase: db, t: t} diff --git a/ui/src/tests/setup.ts b/ui/src/tests/setup.ts index 6aeb9d44..4f7e5bdd 100644 --- a/ui/src/tests/setup.ts +++ b/ui/src/tests/setup.ts @@ -65,7 +65,7 @@ const testPluginDir = (): {dir: string; generator: () => string} => { const dirName = 'gotifyplugin_' + random; const dir = path.join(testBuildPath, dirName); if (!fs.existsSync(dir)) { - fs.mkdirSync(dir, 0o755); + fs.mkdirSync(dir, {recursive: true, mode: 0o755}); } return { dir, @@ -105,7 +105,7 @@ const buildGoExecutable = (filename: string): Promise => { const envGotify = process.env.GOTIFY_EXE; if (envGotify) { if (!fs.existsSync(testBuildPath)) { - fs.mkdirSync(testBuildPath); + fs.mkdirSync(testBuildPath, {recursive: true}); } fs.copyFileSync(envGotify, filename); process.stdout.write(`### Copying ${envGotify} to ${filename}\n`); From 58084c8dea5790796e34540b68d70d4be57395d3 Mon Sep 17 00:00:00 2001 From: Moin Ahmad <48400531+moinologics@users.noreply.github.com> Date: Sun, 22 Sep 2024 22:32:48 +0530 Subject: [PATCH 2/2] implement HEAD /health (#688) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 饺子w (Yumechi) --- router/router.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/router/router.go b/router/router.go index 8b1d3641..aacd072a 100644 --- a/router/router.go +++ b/router/router.go @@ -104,7 +104,7 @@ func Create(db *database.GormDatabase, vInfo *model.VersionInfo, conf *config.Co ui.Register(g, *vInfo, conf.Registration) - g.GET("/health", healthHandler.Health) + g.Match([]string{"GET", "HEAD"}, "/health", healthHandler.Health) g.GET("/swagger", docs.Serve) g.StaticFS("/image", &onlyImageFS{inner: gin.Dir(conf.UploadedImagesDir, false)})