test: fix random boltdb filename

This commit is contained in:
fiftin 2024-07-14 14:10:48 +05:00
parent 7b42f3fcff
commit 3bd1161926
No known key found for this signature in database
GPG Key ID: 044381366A5D4731

View File

@ -1,15 +1,12 @@
package tasks
import (
"github.com/ansible-semaphore/semaphore/db_lib"
"math/rand"
"os"
"path"
"strconv"
"strings"
"testing"
"time"
"github.com/ansible-semaphore/semaphore/db_lib"
"github.com/ansible-semaphore/semaphore/db"
"github.com/ansible-semaphore/semaphore/db/bolt"
@ -17,8 +14,8 @@ import (
)
func CreateBoltDB() db.Store {
r := rand.New(rand.NewSource(time.Now().UTC().UnixNano()))
fn := "/tmp/test_semaphore_db_" + strconv.Itoa(r.Int())
fn := "/tmp/test_semaphore_db_" + util.RandString(5)
store := bolt.BoltDb{
Filename: fn,
}
@ -35,8 +32,6 @@ func TestTaskRunnerRun(t *testing.T) {
store := CreateBoltDB()
//defer store.Close()
pool := CreateTaskPool(store)
go pool.Run()
@ -170,7 +165,6 @@ func TestGetRepoPath_whenStartsWithSlash(t *testing.T) {
func TestPopulateDetails(t *testing.T) {
store := CreateBoltDB()
store.Connect()
proj, err := store.CreateProject(db.Project{})
if err != nil {