navidrome/repositories/base_repository_test.go
2016-02-29 10:04:30 -05:00

45 lines
969 B
Go

package repositories
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
"github.com/deluan/gosonic/tests"
)
func TestUnitBaseRepository(t *testing.T) {
tests.Init(t, false)
Convey("Subject: NewId", t, func() {
repo := &BaseRepository{table: "test_table"}
Convey("When I call NewId with a name", func() {
Id := repo.NewId("a name")
Convey("Then it should return a new Id", func() {
So(Id, ShouldNotBeEmpty)
})
})
Convey("When I call NewId with the same name twice", func() {
FirstId := repo.NewId("a name")
SecondId := repo.NewId("a name")
Convey("Then it should return the same Id each time", func() {
So(FirstId, ShouldEqual, SecondId)
})
})
Convey("When I call NewId with different names", func() {
FirstId := repo.NewId("first name")
SecondId := repo.NewId("second name")
Convey("Then it should return different Ids", func() {
So(FirstId, ShouldNotEqual, SecondId)
})
})
})
}