2020-01-14 18:23:29 -05:00
|
|
|
package persistence
|
2020-01-12 21:46:40 -05:00
|
|
|
|
|
|
|
|
import (
|
2020-04-26 12:06:38 -04:00
|
|
|
"context"
|
|
|
|
|
|
|
|
|
|
"github.com/navidrome/navidrome/log"
|
2020-01-23 19:44:08 -05:00
|
|
|
"github.com/navidrome/navidrome/model"
|
2022-07-26 16:47:16 -04:00
|
|
|
. "github.com/onsi/ginkgo/v2"
|
2020-01-12 21:46:40 -05:00
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
|
)
|
|
|
|
|
|
2020-01-28 08:22:17 -05:00
|
|
|
var _ = Describe("Property Repository", func() {
|
|
|
|
|
var pr model.PropertyRepository
|
2020-01-12 21:46:40 -05:00
|
|
|
|
|
|
|
|
BeforeEach(func() {
|
2024-11-18 15:52:13 +02:00
|
|
|
pr = NewPropertyRepository(log.NewContext(context.TODO()), GetDBXBuilder())
|
2020-01-12 21:46:40 -05:00
|
|
|
})
|
|
|
|
|
|
2020-01-28 08:22:17 -05: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-12 21:46:40 -05:00
|
|
|
})
|
|
|
|
|
|
2020-01-28 08:22:17 -05:00
|
|
|
It("updates a property", func() {
|
|
|
|
|
Expect(pr.Put("1", "another_value")).To(BeNil())
|
|
|
|
|
Expect(pr.Get("1")).To(Equal("another_value"))
|
2020-01-12 21:46:40 -05:00
|
|
|
})
|
|
|
|
|
|
2020-01-28 08:22:17 -05:00
|
|
|
It("returns a default value if property does not exist", func() {
|
|
|
|
|
Expect(pr.DefaultGet("2", "default")).To(Equal("default"))
|
2020-01-12 21:46:40 -05:00
|
|
|
})
|
|
|
|
|
})
|