Skip to content

Commit a58b0be

Browse files
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 <yume@yumechi.jp> --------- Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
1 parent a8a4fef commit a58b0be

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

test/testdb/database.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ type MessageBuilder struct {
3030

3131
// NewDBWithDefaultUser creates a new test db instance with the default user.
3232
func NewDBWithDefaultUser(t *testing.T) *Database {
33-
db, err := database.New("sqlite3", fmt.Sprintf("file:%s?mode=memory&cache=shared", fmt.Sprint(time.Now().Unix())), "admin", "pw", 5, true)
33+
db, err := database.New("sqlite3", fmt.Sprintf("file:%s?mode=memory&cache=shared", fmt.Sprint(time.Now().UnixNano())), "admin", "pw", 5, true)
3434
assert.Nil(t, err)
3535
assert.NotNil(t, db)
3636
return &Database{GormDatabase: db, t: t}
3737
}
3838

3939
// NewDB creates a new test db instance.
4040
func NewDB(t *testing.T) *Database {
41-
db, err := database.New("sqlite3", fmt.Sprintf("file:%s?mode=memory&cache=shared", fmt.Sprint(time.Now().Unix())), "admin", "pw", 5, false)
41+
db, err := database.New("sqlite3", fmt.Sprintf("file:%s?mode=memory&cache=shared", fmt.Sprint(time.Now().UnixNano())), "admin", "pw", 5, false)
4242
assert.Nil(t, err)
4343
assert.NotNil(t, db)
4444
return &Database{GormDatabase: db, t: t}

ui/src/tests/setup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const testPluginDir = (): {dir: string; generator: () => string} => {
6565
const dirName = 'gotifyplugin_' + random;
6666
const dir = path.join(testBuildPath, dirName);
6767
if (!fs.existsSync(dir)) {
68-
fs.mkdirSync(dir, 0o755);
68+
fs.mkdirSync(dir, {recursive: true, mode: 0o755});
6969
}
7070
return {
7171
dir,
@@ -105,7 +105,7 @@ const buildGoExecutable = (filename: string): Promise<void> => {
105105
const envGotify = process.env.GOTIFY_EXE;
106106
if (envGotify) {
107107
if (!fs.existsSync(testBuildPath)) {
108-
fs.mkdirSync(testBuildPath);
108+
fs.mkdirSync(testBuildPath, {recursive: true});
109109
}
110110
fs.copyFileSync(envGotify, filename);
111111
process.stdout.write(`### Copying ${envGotify} to ${filename}\n`);

0 commit comments

Comments
 (0)