quintodrome/persistence/db_storm/storm_suite_test.go

50 lines
1.2 KiB
Go
Raw Normal View History

2020-01-10 15:41:35 -09:00
package db_storm
2020-01-10 11:08:23 -09:00
import (
2020-01-11 12:47:26 -09:00
"io/ioutil"
"os"
2020-01-10 11:08:23 -09:00
"testing"
2020-01-11 12:47:26 -09:00
"github.com/cloudsonic/sonic-server/conf"
"github.com/cloudsonic/sonic-server/domain"
2020-01-11 12:47:26 -09:00
"github.com/cloudsonic/sonic-server/log"
2020-01-10 11:08:23 -09:00
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
func TestStormPersistence(t *testing.T) {
2020-01-11 12:47:26 -09:00
log.SetLevel(log.LevelCritical)
2020-01-10 11:08:23 -09:00
RegisterFailHandler(Fail)
RunSpecs(t, "Storm Persistence Suite")
}
var testAlbums = domain.Albums{
{ID: "1", Name: "Sgt Peppers", Artist: "The Beatles", ArtistID: "1"},
{ID: "2", Name: "Abbey Road", Artist: "The Beatles", ArtistID: "1"},
{ID: "3", Name: "Radioactivity", Artist: "Kraftwerk", ArtistID: "2", Starred: true},
}
var testArtists = domain.Artists{
{ID: "1", Name: "Saara Saara"},
{ID: "2", Name: "Kraftwerk"},
{ID: "3", Name: "The Beatles"},
}
var _ = Describe("Initialize test DB", func() {
BeforeSuite(func() {
2020-01-11 12:47:26 -09:00
conf.Sonic.DbPath, _ = ioutil.TempDir("", "cloudsonic_tests")
os.MkdirAll(conf.Sonic.DbPath, 0700)
Db().Drop(&_Album{})
albumRepo := NewAlbumRepository()
for _, a := range testAlbums {
albumRepo.Put(&a)
}
Db().Drop(&_Artist{})
artistRepo := NewArtistRepository()
for _, a := range testArtists {
artistRepo.Put(&a)
}
})
})