Skip to content

🎧 Your Personal Streaming Service

Fixing some lint warnings

Deluan83e0a7b24c8f
diff --git a/engine/browser.go b/engine/browser.go
index 5be7cad84..0df6bbe30 100644
--- a/engine/browser.go
+++ b/engine/browser.go
@@ -1,7 +1,6 @@
package engine
import (
- "errors"
"fmt"
"strconv"
"time"
@@ -42,7 +41,7 @@ func (b *browser) Indexes(ifModifiedSince time.Time) (domain.ArtistIndexes, time
lastModified := utils.ToTime(ms)
if err != nil {
- return nil, time.Time{}, errors.New(fmt.Sprintf("error retrieving LastScan property: %v", err))
+ return nil, time.Time{}, fmt.Errorf("error retrieving LastScan property: %v", err)
}
if lastModified.After(ifModifiedSince) {
diff --git a/persistence/ledis_repository.go b/persistence/ledis_repository.go
index 01dfedff3..194ac1f13 100644
--- a/persistence/ledis_repository.go
+++ b/persistence/ledis_repository.go
@@ -331,7 +331,7 @@ func (r *ledisRepository) loadFromSet(setName string, entities interface{}, qo .
}
reflected := reflect.ValueOf(entities).Elem()
- var sortKey []byte = nil
+ var sortKey []byte
if o.SortBy != "" {
sortKey = []byte(fmt.Sprintf("%s:*:%s", r.table, o.SortBy))
}
diff --git a/persistence/ledis_repository_test.go b/persistence/ledis_repository_test.go
index f00acece7..8352945fb 100644
--- a/persistence/ledis_repository_test.go
+++ b/persistence/ledis_repository_test.go
@@ -143,7 +143,7 @@ func TestBaseRepository(t *testing.T) {
})
Convey("And the number of children should be 1", func() {
- children := make([]TestEntity, 0)
+ var children []TestEntity
err := repo.loadChildren("parent", "ABC", &children)
So(err, ShouldBeNil)
So(len(children), ShouldEqual, 1)
@@ -241,7 +241,7 @@ func TestBaseRepository(t *testing.T) {
So(count, ShouldEqual, 2)
})
Convey("And the deleted record shouldn't be among the children", func() {
- children := make([]TestEntity, 0)
+ var children []TestEntity
err := repo.loadChildren("parent", "AAA", &children)
So(err, ShouldBeNil)
So(len(children), ShouldEqual, 2)
diff --git a/tests/matchers.go b/tests/matchers.go
index 33009d2f0..f5dc161d8 100644
--- a/tests/matchers.go
+++ b/tests/matchers.go
@@ -6,8 +6,9 @@ import (
"encoding/json"
"encoding/xml"
"fmt"
+
"github.com/deluan/gosonic/api/responses"
- . "github.com/smartystreets/goconvey/convey"
+ "github.com/smartystreets/goconvey/convey"
)
func ShouldMatchXML(actual interface{}, expected ...interface{}) string {
@@ -15,7 +16,7 @@ func ShouldMatchXML(actual interface{}, expected ...interface{}) string {
if err != nil {
return fmt.Sprintf("Malformed XML: %v", err)
}
- return ShouldEqual(string(xml), expected[0].(string))
+ return convey.ShouldEqual(string(xml), expected[0].(string))
}
@@ -25,13 +26,13 @@ func ShouldMatchJSON(actual interface{}, expected ...interface{}) string {
return fmt.Sprintf("Malformed JSON: %v", err)
}
s := UnindentJSON(json)
- return ShouldEqual(s, expected[0].(string))
+ return convey.ShouldEqual(s, expected[0].(string))
}
func ShouldContainJSON(actual interface{}, expected ...interface{}) string {
a := UnindentJSON(actual.(*bytes.Buffer).Bytes())
- return ShouldContainSubstring(a, expected[0].(string))
+ return convey.ShouldContainSubstring(a, expected[0].(string))
}
func ShouldReceiveError(actual interface{}, expected ...interface{}) string {
@@ -41,12 +42,12 @@ func ShouldReceiveError(actual interface{}, expected ...interface{}) string {
return fmt.Sprintf("Malformed XML: %v", err)
}
- return ShouldEqual(v.Error.Code, expected[0].(int))
+ return convey.ShouldEqual(v.Error.Code, expected[0].(int))
}
func ShouldMatchMD5(actual interface{}, expected ...interface{}) string {
a := fmt.Sprintf("%x", md5.Sum(actual.([]byte)))
- return ShouldEqual(a, expected[0].(string))
+ return convey.ShouldEqual(a, expected[0].(string))
}
func ShouldBeAValid(actual interface{}, expected ...interface{}) string {