Change tests' db path to a temp folder

This commit is contained in:
Deluan 2020-01-11 16:47:26 -05:00
parent 4b1c909a4d
commit 6c05930444
2 changed files with 7 additions and 4 deletions

View File

@ -1,10 +1,8 @@
package db_storm
import (
"fmt"
"os"
"path"
"path/filepath"
"sync"
"github.com/asdine/storm"
@ -24,7 +22,6 @@ func Db() *storm.DB {
panic(err)
}
dbPath := path.Join(conf.Sonic.DbPath, "storm.db")
dbPath = fmt.Sprintf(".%c%s", filepath.Separator, dbPath)
instance, err := storm.Open(dbPath)
log.Debug("Opening Storm DB from: " + dbPath)
if err != nil {

View File

@ -1,15 +1,19 @@
package db_storm
import (
"io/ioutil"
"os"
"testing"
"github.com/cloudsonic/sonic-server/conf"
"github.com/cloudsonic/sonic-server/domain"
"github.com/cloudsonic/sonic-server/log"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
func TestStormPersistence(t *testing.T) {
//log.SetLevel(log.LevelCritical)
log.SetLevel(log.LevelCritical)
RegisterFailHandler(Fail)
RunSpecs(t, "Storm Persistence Suite")
}
@ -27,6 +31,8 @@ var testArtists = domain.Artists{
var _ = Describe("Initialize test DB", func() {
BeforeSuite(func() {
conf.Sonic.DbPath, _ = ioutil.TempDir("", "cloudsonic_tests")
os.MkdirAll(conf.Sonic.DbPath, 0700)
Db().Drop(&_Album{})
albumRepo := NewAlbumRepository()
for _, a := range testAlbums {