2020-01-28 04:22:17 -09:00
|
|
|
package persistence_test
|
2020-01-15 13:49:09 -09:00
|
|
|
|
|
|
|
|
import (
|
2020-04-26 08:06:38 -08:00
|
|
|
"context"
|
|
|
|
|
|
2020-01-19 11:37:41 -09:00
|
|
|
"github.com/astaxie/beego/orm"
|
2020-01-31 05:53:19 -09:00
|
|
|
"github.com/deluan/navidrome/log"
|
2020-01-23 15:44:08 -09:00
|
|
|
"github.com/deluan/navidrome/model"
|
2020-01-28 04:22:17 -09:00
|
|
|
"github.com/deluan/navidrome/persistence"
|
2020-01-15 13:49:09 -09:00
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var _ = Describe("GenreRepository", func() {
|
|
|
|
|
var repo model.GenreRepository
|
|
|
|
|
|
|
|
|
|
BeforeEach(func() {
|
2020-04-26 08:06:38 -08:00
|
|
|
repo = persistence.NewGenreRepository(log.NewContext(context.TODO()), orm.NewOrm())
|
2020-01-15 13:49:09 -09:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
It("returns all records", func() {
|
|
|
|
|
genres, err := repo.GetAll()
|
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
|
Expect(genres).To(ContainElement(model.Genre{Name: "Rock", AlbumCount: 2, SongCount: 2}))
|
|
|
|
|
Expect(genres).To(ContainElement(model.Genre{Name: "Electronic", AlbumCount: 1, SongCount: 2}))
|
|
|
|
|
})
|
|
|
|
|
})
|