2020-01-15 00:23:29 +01:00
|
|
|
package persistence
|
2020-01-13 03:46:40 +01:00
|
|
|
|
|
|
|
import (
|
2020-01-28 14:22:17 +01:00
|
|
|
"context"
|
|
|
|
|
2020-01-19 21:37:41 +01:00
|
|
|
"github.com/astaxie/beego/orm"
|
2020-01-24 01:44:08 +01:00
|
|
|
"github.com/deluan/navidrome/model"
|
2020-01-13 03:46:40 +01:00
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
)
|
|
|
|
|
2020-01-28 14:22:17 +01:00
|
|
|
var _ = Describe("Property Repository", func() {
|
|
|
|
var pr model.PropertyRepository
|
2020-01-13 03:46:40 +01:00
|
|
|
|
|
|
|
BeforeEach(func() {
|
2020-01-28 14:22:17 +01:00
|
|
|
pr = NewPropertyRepository(context.Background(), orm.NewOrm())
|
2020-01-13 03:46:40 +01:00
|
|
|
})
|
|
|
|
|
2020-01-28 14:22:17 +01:00
|
|
|
It("saves and restore a new property", func() {
|
|
|
|
id := "1"
|
|
|
|
value := "a_value"
|
|
|
|
Expect(pr.Put(id, value)).To(BeNil())
|
|
|
|
Expect(pr.Get(id)).To(Equal("a_value"))
|
2020-01-13 03:46:40 +01:00
|
|
|
})
|
|
|
|
|
2020-01-28 14:22:17 +01:00
|
|
|
It("updates a property", func() {
|
|
|
|
Expect(pr.Put("1", "another_value")).To(BeNil())
|
|
|
|
Expect(pr.Get("1")).To(Equal("another_value"))
|
2020-01-13 03:46:40 +01:00
|
|
|
})
|
|
|
|
|
2020-01-28 14:22:17 +01:00
|
|
|
It("returns a default value if property does not exist", func() {
|
|
|
|
Expect(pr.DefaultGet("2", "default")).To(Equal("default"))
|
2020-01-13 03:46:40 +01:00
|
|
|
})
|
|
|
|
})
|