Removed unused code
This commit is contained in:
@@ -9,7 +9,6 @@ type ArtistRepository interface {
|
|||||||
BaseRepository
|
BaseRepository
|
||||||
Put(m *Artist) error
|
Put(m *Artist) error
|
||||||
Get(id string) (*Artist, error)
|
Get(id string) (*Artist, error)
|
||||||
GetByName(name string) (*Artist, error)
|
|
||||||
PurgeInactive(active Artists) ([]string, error)
|
PurgeInactive(active Artists) ([]string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package domain
|
|||||||
import "errors"
|
import "errors"
|
||||||
|
|
||||||
type BaseRepository interface {
|
type BaseRepository interface {
|
||||||
NewId(fields ...string) string
|
|
||||||
CountAll() (int64, error)
|
CountAll() (int64, error)
|
||||||
Exists(id string) (bool, error)
|
Exists(id string) (bool, error)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,11 +29,6 @@ func (r *artistRepository) Get(id string) (*domain.Artist, error) {
|
|||||||
return rec.(*domain.Artist), err
|
return rec.(*domain.Artist), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *artistRepository) GetByName(name string) (*domain.Artist, error) {
|
|
||||||
id := r.NewId(name)
|
|
||||||
return r.Get(id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *artistRepository) PurgeInactive(active domain.Artists) ([]string, error) {
|
func (r *artistRepository) PurgeInactive(active domain.Artists) ([]string, error) {
|
||||||
return r.purgeInactive(active, func(e interface{}) string {
|
return r.purgeInactive(active, func(e interface{}) string {
|
||||||
return e.(domain.Artist).Id
|
return e.(domain.Artist).Id
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ func (r *ledisRepository) parseAnnotations(entity interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO Use annotations to specify fields to be used
|
// TODO Use annotations to specify fields to be used
|
||||||
func (r *ledisRepository) NewId(fields ...string) string {
|
func (r *ledisRepository) newId(fields ...string) string {
|
||||||
s := fmt.Sprintf("%s\\%s", strings.ToUpper(r.table), strings.Join(fields, ""))
|
s := fmt.Sprintf("%s\\%s", strings.ToUpper(r.table), strings.Join(fields, ""))
|
||||||
return fmt.Sprintf("%x", md5.Sum([]byte(s)))
|
return fmt.Sprintf("%x", md5.Sum([]byte(s)))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,15 +90,15 @@ func TestBaseRepository(t *testing.T) {
|
|||||||
repo := createEmptyRepo()
|
repo := createEmptyRepo()
|
||||||
|
|
||||||
Convey("When I call NewId with a name", func() {
|
Convey("When I call NewId with a name", func() {
|
||||||
Id := repo.NewId("a name")
|
Id := repo.newId("a name")
|
||||||
Convey("Then it should return a new Id", func() {
|
Convey("Then it should return a new Id", func() {
|
||||||
So(Id, ShouldNotBeEmpty)
|
So(Id, ShouldNotBeEmpty)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("When I call NewId with the same name twice", func() {
|
Convey("When I call NewId with the same name twice", func() {
|
||||||
FirstId := repo.NewId("a name")
|
FirstId := repo.newId("a name")
|
||||||
SecondId := repo.NewId("a name")
|
SecondId := repo.newId("a name")
|
||||||
|
|
||||||
Convey("Then it should return the same Id each time", func() {
|
Convey("Then it should return the same Id each time", func() {
|
||||||
So(FirstId, ShouldEqual, SecondId)
|
So(FirstId, ShouldEqual, SecondId)
|
||||||
@@ -107,8 +107,8 @@ func TestBaseRepository(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Convey("When I call NewId with different names", func() {
|
Convey("When I call NewId with different names", func() {
|
||||||
FirstId := repo.NewId("first name")
|
FirstId := repo.newId("first name")
|
||||||
SecondId := repo.NewId("second name")
|
SecondId := repo.newId("second name")
|
||||||
|
|
||||||
Convey("Then it should return different Ids", func() {
|
Convey("Then it should return different Ids", func() {
|
||||||
So(FirstId, ShouldNotEqual, SecondId)
|
So(FirstId, ShouldNotEqual, SecondId)
|
||||||
|
|||||||
Reference in New Issue
Block a user