Some small refactorings

This commit is contained in:
Deluan
2021-08-22 11:46:52 -04:00
parent c2927e105b
commit d481864035
10 changed files with 137 additions and 94 deletions
+10 -10
View File
@@ -4,8 +4,8 @@ import "github.com/navidrome/navidrome/model"
type MockedUserPropsRepo struct {
model.UserPropsRepository
data map[string]string
err error
Error error
data map[string]string
}
func (p *MockedUserPropsRepo) init() {
@@ -15,8 +15,8 @@ func (p *MockedUserPropsRepo) init() {
}
func (p *MockedUserPropsRepo) Put(userId, key string, value string) error {
if p.err != nil {
return p.err
if p.Error != nil {
return p.Error
}
p.init()
p.data[userId+key] = value
@@ -24,8 +24,8 @@ func (p *MockedUserPropsRepo) Put(userId, key string, value string) error {
}
func (p *MockedUserPropsRepo) Get(userId, key string) (string, error) {
if p.err != nil {
return "", p.err
if p.Error != nil {
return "", p.Error
}
p.init()
if v, ok := p.data[userId+key]; ok {
@@ -35,8 +35,8 @@ func (p *MockedUserPropsRepo) Get(userId, key string) (string, error) {
}
func (p *MockedUserPropsRepo) Delete(userId, key string) error {
if p.err != nil {
return p.err
if p.Error != nil {
return p.Error
}
p.init()
if _, ok := p.data[userId+key]; ok {
@@ -47,8 +47,8 @@ func (p *MockedUserPropsRepo) Delete(userId, key string) error {
}
func (p *MockedUserPropsRepo) DefaultGet(userId, key string, defaultValue string) (string, error) {
if p.err != nil {
return "", p.err
if p.Error != nil {
return "", p.Error
}
p.init()
v, err := p.Get(userId, key)