diff --git a/model/checksum.go b/model/checksum.go deleted file mode 100644 index 3999105d9..000000000 --- a/model/checksum.go +++ /dev/null @@ -1,8 +0,0 @@ -package model - -type ChecksumMap map[string]string - -type ChecksumRepository interface { - GetData() (ChecksumMap, error) - SetData(newSums ChecksumMap) error -} diff --git a/persistence/checksum_repository.go b/persistence/checksum_repository.go deleted file mode 100644 index 0c63cc37b..000000000 --- a/persistence/checksum_repository.go +++ /dev/null @@ -1,58 +0,0 @@ -package persistence - -import ( - "github.com/astaxie/beego/orm" - "github.com/cloudsonic/sonic-server/model" -) - -type checkSumRepository struct { - ormer orm.Ormer -} - -const checkSumId = "1" - -type checksum struct { - ID string `orm:"pk;column(id)"` - Sum string -} - -func NewCheckSumRepository(o orm.Ormer) model.ChecksumRepository { - r := &checkSumRepository{ormer: o} - return r -} - -func (r *checkSumRepository) GetData() (model.ChecksumMap, error) { - loadedData := make(map[string]string) - - var all []checksum - _, err := r.ormer.QueryTable(&checksum{}).Limit(-1).All(&all) - if err != nil { - return nil, err - } - - for _, cks := range all { - loadedData[cks.ID] = cks.Sum - } - - return loadedData, nil -} - -func (r *checkSumRepository) SetData(newSums model.ChecksumMap) error { - _, err := r.ormer.Raw("delete from checksum").Exec() - if err != nil { - return err - } - - var checksums []checksum - for k, v := range newSums { - cks := checksum{ID: k, Sum: v} - checksums = append(checksums, cks) - } - _, err = r.ormer.InsertMulti(batchSize, &checksums) - if err != nil { - return err - } - return nil -} - -var _ model.ChecksumRepository = (*checkSumRepository)(nil) diff --git a/persistence/checksum_repository_test.go b/persistence/checksum_repository_test.go deleted file mode 100644 index babb3de5c..000000000 --- a/persistence/checksum_repository_test.go +++ /dev/null @@ -1,35 +0,0 @@ -package persistence - -import ( - "github.com/astaxie/beego/orm" - "github.com/cloudsonic/sonic-server/model" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("ChecksumRepository", func() { - var repo model.ChecksumRepository - - BeforeEach(func() { - repo = NewCheckSumRepository(orm.NewOrm()) - err := repo.SetData(map[string]string{ - "a": "AAA", "b": "BBB", - }) - if err != nil { - panic(err) - } - }) - - It("can retrieve data", func() { - sums, err := repo.GetData() - Expect(err).To(BeNil()) - Expect(sums["b"]).To(Equal("BBB")) - }) - - It("persists data", func() { - newRepo := NewCheckSumRepository(orm.NewOrm()) - sums, err := newRepo.GetData() - Expect(err).To(BeNil()) - Expect(sums["b"]).To(Equal("BBB")) - }) -}) diff --git a/persistence/persistence.go b/persistence/persistence.go index 35cc1f302..59969f39a 100644 --- a/persistence/persistence.go +++ b/persistence/persistence.go @@ -165,6 +165,5 @@ func init() { registerModel(model.User{}, new(user)) registerModel(model.Annotation{}, new(annotation)) - orm.RegisterModel(new(checksum)) orm.RegisterModel(new(search)) }