Retrofitting with tests

This commit is contained in:
Deluan
2016-02-29 10:04:30 -05:00
parent ec9398f2bd
commit b0bd0a63a7
8 changed files with 2057 additions and 11 deletions
+44
View File
@@ -0,0 +1,44 @@
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)
})
})
})
}