SQL/Orm PropertyRepository complete

This commit is contained in:
Deluan 2020-01-12 21:46:40 -05:00 committed by Deluan Quintão
parent 3d706e3e98
commit 5d519dcecf
5 changed files with 88 additions and 2 deletions

View file

@ -0,0 +1,30 @@
package db_sql
import (
"github.com/cloudsonic/sonic-server/domain"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("PropertyRepository", func() {
var repo domain.PropertyRepository
BeforeEach(func() {
Db().QueryTable("property").Exclude("id", ".PHONY").Delete()
repo = NewPropertyRepository()
})
It("saves and retrieves data", func() {
Expect(repo.Put("1", "test")).To(BeNil())
Expect(repo.Get("1")).To(Equal("test"))
})
It("returns default if data is not found", func() {
Expect(repo.DefaultGet("2", "default")).To(Equal("default"))
})
It("returns value if found", func() {
Expect(repo.Put("3", "test")).To(BeNil())
Expect(repo.DefaultGet("3", "default")).To(Equal("test"))
})
})