2020-01-15 00:23:29 +01:00
|
|
|
package persistence
|
2020-01-13 01:46:45 +01:00
|
|
|
|
|
|
|
import (
|
2020-01-15 04:22:34 +01:00
|
|
|
"github.com/cloudsonic/sonic-server/model"
|
2020-01-13 01:46:45 +01:00
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ = Describe("ChecksumRepository", func() {
|
2020-01-15 14:54:00 +01:00
|
|
|
var repo model.ChecksumRepository
|
2020-01-13 01:46:45 +01:00
|
|
|
|
|
|
|
BeforeEach(func() {
|
2020-01-13 14:35:12 +01:00
|
|
|
Db().Delete(&Checksum{ID: checkSumId})
|
2020-01-13 01:46:45 +01:00
|
|
|
repo = NewCheckSumRepository()
|
|
|
|
err := repo.SetData(map[string]string{
|
|
|
|
"a": "AAA", "b": "BBB",
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
It("can retrieve data", func() {
|
2020-01-15 14:54:00 +01:00
|
|
|
sums, err := repo.GetData()
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
Expect(sums["b"]).To(Equal("BBB"))
|
2020-01-13 01:46:45 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
It("persists data", func() {
|
|
|
|
newRepo := NewCheckSumRepository()
|
2020-01-15 14:54:00 +01:00
|
|
|
sums, err := newRepo.GetData()
|
|
|
|
Expect(err).To(BeNil())
|
|
|
|
Expect(sums["b"]).To(Equal("BBB"))
|
2020-01-13 01:46:45 +01:00
|
|
|
})
|
|
|
|
})
|