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>
This commit is contained in:
parent
a8a4fefd86
commit
a58b0be362
|
|
@ -30,7 +30,7 @@ type MessageBuilder struct {
|
||||||
|
|
||||||
// NewDBWithDefaultUser creates a new test db instance with the default user.
|
// NewDBWithDefaultUser creates a new test db instance with the default user.
|
||||||
func NewDBWithDefaultUser(t *testing.T) *Database {
|
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.Nil(t, err)
|
||||||
assert.NotNil(t, db)
|
assert.NotNil(t, db)
|
||||||
return &Database{GormDatabase: db, t: t}
|
return &Database{GormDatabase: db, t: t}
|
||||||
|
|
@ -38,7 +38,7 @@ func NewDBWithDefaultUser(t *testing.T) *Database {
|
||||||
|
|
||||||
// NewDB creates a new test db instance.
|
// NewDB creates a new test db instance.
|
||||||
func NewDB(t *testing.T) *Database {
|
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.Nil(t, err)
|
||||||
assert.NotNil(t, db)
|
assert.NotNil(t, db)
|
||||||
return &Database{GormDatabase: db, t: t}
|
return &Database{GormDatabase: db, t: t}
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ const testPluginDir = (): {dir: string; generator: () => string} => {
|
||||||
const dirName = 'gotifyplugin_' + random;
|
const dirName = 'gotifyplugin_' + random;
|
||||||
const dir = path.join(testBuildPath, dirName);
|
const dir = path.join(testBuildPath, dirName);
|
||||||
if (!fs.existsSync(dir)) {
|
if (!fs.existsSync(dir)) {
|
||||||
fs.mkdirSync(dir, 0o755);
|
fs.mkdirSync(dir, {recursive: true, mode: 0o755});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
dir,
|
dir,
|
||||||
|
|
@ -105,7 +105,7 @@ const buildGoExecutable = (filename: string): Promise<void> => {
|
||||||
const envGotify = process.env.GOTIFY_EXE;
|
const envGotify = process.env.GOTIFY_EXE;
|
||||||
if (envGotify) {
|
if (envGotify) {
|
||||||
if (!fs.existsSync(testBuildPath)) {
|
if (!fs.existsSync(testBuildPath)) {
|
||||||
fs.mkdirSync(testBuildPath);
|
fs.mkdirSync(testBuildPath, {recursive: true});
|
||||||
}
|
}
|
||||||
fs.copyFileSync(envGotify, filename);
|
fs.copyFileSync(envGotify, filename);
|
||||||
process.stdout.write(`### Copying ${envGotify} to ${filename}\n`);
|
process.stdout.write(`### Copying ${envGotify} to ${filename}\n`);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue