Renamed Id to ID, following GoLang convention
This commit is contained in:
@@ -18,10 +18,10 @@ func NewAlbumRepository() domain.AlbumRepository {
|
||||
}
|
||||
|
||||
func (r *albumRepository) Put(m *domain.Album) error {
|
||||
if m.Id == "" {
|
||||
return errors.New("album Id is not set")
|
||||
if m.ID == "" {
|
||||
return errors.New("album ID is not set")
|
||||
}
|
||||
return r.saveOrUpdate(m.Id, m)
|
||||
return r.saveOrUpdate(m.ID, m)
|
||||
}
|
||||
|
||||
func (r *albumRepository) Get(id string) (*domain.Album, error) {
|
||||
@@ -60,7 +60,7 @@ func (r *albumRepository) GetAllIds() ([]string, error) {
|
||||
|
||||
func (r *albumRepository) PurgeInactive(active domain.Albums) ([]string, error) {
|
||||
return r.purgeInactive(active, func(e interface{}) string {
|
||||
return e.(domain.Album).Id
|
||||
return e.(domain.Album).ID
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -17,10 +17,10 @@ func NewArtistRepository() domain.ArtistRepository {
|
||||
}
|
||||
|
||||
func (r *artistRepository) Put(m *domain.Artist) error {
|
||||
if m.Id == "" {
|
||||
return errors.New("artist Id is not set")
|
||||
if m.ID == "" {
|
||||
return errors.New("artist ID is not set")
|
||||
}
|
||||
return r.saveOrUpdate(m.Id, m)
|
||||
return r.saveOrUpdate(m.ID, m)
|
||||
}
|
||||
|
||||
func (r *artistRepository) Get(id string) (*domain.Artist, error) {
|
||||
@@ -31,7 +31,7 @@ func (r *artistRepository) Get(id string) (*domain.Artist, error) {
|
||||
|
||||
func (r *artistRepository) PurgeInactive(active domain.Artists) ([]string, error) {
|
||||
return r.purgeInactive(active, func(e interface{}) string {
|
||||
return e.(domain.Artist).Id
|
||||
return e.(domain.Artist).ID
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ func (r *checkSumRepository) loadData() {
|
||||
|
||||
func (r *checkSumRepository) Put(id, sum string) error {
|
||||
if id == "" {
|
||||
return errors.New("Id is required")
|
||||
return errors.New("ID is required")
|
||||
}
|
||||
_, err := Db().HSet(checkSumKeyName, []byte(id), []byte(sum))
|
||||
return err
|
||||
|
||||
@@ -19,7 +19,7 @@ func NewArtistIndexRepository() domain.ArtistIndexRepository {
|
||||
|
||||
func (r *artistIndexRepository) Put(m *domain.ArtistIndex) error {
|
||||
if m.Id == "" {
|
||||
return errors.New("index Id is not set")
|
||||
return errors.New("index ID is not set")
|
||||
}
|
||||
sort.Sort(m.Artists)
|
||||
return r.saveOrUpdate(m.Id, m)
|
||||
|
||||
@@ -24,7 +24,7 @@ func TestIndexRepository(t *testing.T) {
|
||||
|
||||
So(s, shouldBeEqual, i)
|
||||
})
|
||||
Convey("It should be able to check for existence of an Id", func() {
|
||||
Convey("It should be able to check for existence of an ID", func() {
|
||||
i := &domain.ArtistIndex{Id: "123"}
|
||||
|
||||
repo.Put(i)
|
||||
@@ -35,7 +35,7 @@ func TestIndexRepository(t *testing.T) {
|
||||
s, _ = repo.Exists("NOT_FOUND")
|
||||
So(s, ShouldBeFalse)
|
||||
})
|
||||
Convey("Method Put() should return error if Id is not set", func() {
|
||||
Convey("Method Put() should return error if ID is not set", func() {
|
||||
i := &domain.ArtistIndex{}
|
||||
|
||||
err := repo.Put(i)
|
||||
|
||||
@@ -91,7 +91,7 @@ func TestBaseRepository(t *testing.T) {
|
||||
|
||||
Convey("When I call NewId with a name", func() {
|
||||
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)
|
||||
})
|
||||
})
|
||||
@@ -100,7 +100,7 @@ func TestBaseRepository(t *testing.T) {
|
||||
FirstId := 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)
|
||||
})
|
||||
|
||||
@@ -163,7 +163,7 @@ func TestBaseRepository(t *testing.T) {
|
||||
entity := &TestEntity{Id: "111", Name: "One Name", ParentId: "AAA"}
|
||||
repo.saveOrUpdate(entity.Id, entity)
|
||||
|
||||
Convey("When I save an entity with a different Id", func() {
|
||||
Convey("When I save an entity with a different ID", func() {
|
||||
newEntity := &TestEntity{Id: "222", Name: "Another Name", ParentId: "AAA"}
|
||||
repo.saveOrUpdate(newEntity.Id, newEntity)
|
||||
|
||||
@@ -174,7 +174,7 @@ func TestBaseRepository(t *testing.T) {
|
||||
|
||||
})
|
||||
|
||||
Convey("When I save an entity with the same Id", func() {
|
||||
Convey("When I save an entity with the same ID", func() {
|
||||
newEntity := &TestEntity{Id: "111", Name: "New Name", ParentId: "AAA"}
|
||||
repo.saveOrUpdate(newEntity.Id, newEntity)
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ func NewMediaFileRepository() domain.MediaFileRepository {
|
||||
}
|
||||
|
||||
func (r *mediaFileRepository) Put(m *domain.MediaFile) error {
|
||||
if m.Id == "" {
|
||||
return errors.New("mediaFile Id is not set")
|
||||
if m.ID == "" {
|
||||
return errors.New("mediaFile ID is not set")
|
||||
}
|
||||
return r.saveOrUpdate(m.Id, m)
|
||||
return r.saveOrUpdate(m.ID, m)
|
||||
}
|
||||
|
||||
func (r *mediaFileRepository) Get(id string) (*domain.MediaFile, error) {
|
||||
@@ -31,7 +31,7 @@ func (r *mediaFileRepository) Get(id string) (*domain.MediaFile, error) {
|
||||
return nil, err
|
||||
}
|
||||
mf := m.(*domain.MediaFile)
|
||||
if mf.Id != id {
|
||||
if mf.ID != id {
|
||||
return nil, nil
|
||||
}
|
||||
return mf, nil
|
||||
@@ -69,7 +69,7 @@ func (r *mediaFileRepository) GetAllIds() ([]string, error) {
|
||||
|
||||
func (r *mediaFileRepository) PurgeInactive(active domain.MediaFiles) ([]string, error) {
|
||||
return r.purgeInactive(active, func(e interface{}) string {
|
||||
return e.(domain.MediaFile).Id
|
||||
return e.(domain.MediaFile).ID
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ func NewMediaFolderRepository() domain.MediaFolderRepository {
|
||||
}
|
||||
|
||||
func (*mediaFolderRepository) GetAll() (domain.MediaFolders, error) {
|
||||
mediaFolder := domain.MediaFolder{Id: "0", Name: "iTunes Library", Path: conf.Sonic.MusicFolder}
|
||||
mediaFolder := domain.MediaFolder{ID: "0", Name: "iTunes Library", Path: conf.Sonic.MusicFolder}
|
||||
result := make(domain.MediaFolders, 1)
|
||||
result[0] = mediaFolder
|
||||
return result, nil
|
||||
|
||||
@@ -17,10 +17,10 @@ func NewPlaylistRepository() domain.PlaylistRepository {
|
||||
}
|
||||
|
||||
func (r *playlistRepository) Put(m *domain.Playlist) error {
|
||||
if m.Id == "" {
|
||||
return errors.New("playlist Id is not set")
|
||||
if m.ID == "" {
|
||||
return errors.New("playlist ID is not set")
|
||||
}
|
||||
return r.saveOrUpdate(m.Id, m)
|
||||
return r.saveOrUpdate(m.ID, m)
|
||||
}
|
||||
|
||||
func (r *playlistRepository) Get(id string) (*domain.Playlist, error) {
|
||||
@@ -41,7 +41,7 @@ func (r *playlistRepository) GetAll(options domain.QueryOptions) (domain.Playlis
|
||||
|
||||
func (r *playlistRepository) PurgeInactive(active domain.Playlists) ([]string, error) {
|
||||
return r.purgeInactive(active, func(e interface{}) string {
|
||||
return e.(domain.Playlist).Id
|
||||
return e.(domain.Playlist).ID
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@ func NewPropertyRepository() domain.PropertyRepository {
|
||||
}
|
||||
|
||||
func (r *propertyRepository) Put(id string, value string) error {
|
||||
m := &domain.Property{Id: id, Value: value}
|
||||
if m.Id == "" {
|
||||
return errors.New("Id is required")
|
||||
m := &domain.Property{ID: id, Value: value}
|
||||
if m.ID == "" {
|
||||
return errors.New("ID is required")
|
||||
}
|
||||
return r.saveOrUpdate(m.Id, m)
|
||||
return r.saveOrUpdate(m.ID, m)
|
||||
}
|
||||
|
||||
func (r *propertyRepository) Get(id string) (string, error) {
|
||||
|
||||
@@ -32,7 +32,7 @@ func (m *MockAlbum) SetData(j string, size int) {
|
||||
fmt.Println("ERROR: ", err)
|
||||
}
|
||||
for _, a := range m.all {
|
||||
m.data[a.Id] = &a
|
||||
m.data[a.ID] = &a
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ func (m *MockAlbum) FindByArtist(artistId string) (domain.Albums, error) {
|
||||
var res = make(domain.Albums, len(m.data))
|
||||
i := 0
|
||||
for _, a := range m.data {
|
||||
if a.ArtistId == artistId {
|
||||
if a.ArtistID == artistId {
|
||||
res[i] = *a
|
||||
i++
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ func (m *MockArtist) SetData(j string, size int) {
|
||||
fmt.Println("ERROR: ", err)
|
||||
}
|
||||
for _, a := range l {
|
||||
m.data[a.Id] = &a
|
||||
m.data[a.ID] = &a
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ func (m *MockMediaFile) SetData(j string, size int) {
|
||||
fmt.Println("ERROR: ", err)
|
||||
}
|
||||
for _, a := range l {
|
||||
m.data[a.Id] = a
|
||||
m.data[a.ID] = a
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ func (m *MockMediaFile) FindByAlbum(artistId string) (domain.MediaFiles, error)
|
||||
var res = make(domain.MediaFiles, len(m.data))
|
||||
i := 0
|
||||
for _, a := range m.data {
|
||||
if a.AlbumId == artistId {
|
||||
if a.AlbumID == artistId {
|
||||
res[i] = a
|
||||
i++
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user