Add more tests
This commit is contained in:
@@ -3,12 +3,10 @@ package persistence
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/navidrome/navidrome/log"
|
|
||||||
|
|
||||||
"github.com/deluan/rest"
|
|
||||||
|
|
||||||
. "github.com/Masterminds/squirrel"
|
. "github.com/Masterminds/squirrel"
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
|
"github.com/deluan/rest"
|
||||||
|
"github.com/navidrome/navidrome/log"
|
||||||
"github.com/navidrome/navidrome/model"
|
"github.com/navidrome/navidrome/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Masterminds/squirrel"
|
"github.com/Masterminds/squirrel"
|
||||||
|
"github.com/navidrome/navidrome/model"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
@@ -58,7 +59,7 @@ var _ = Describe("Helpers", func() {
|
|||||||
e := exists("album", squirrel.Eq{"id": 1})
|
e := exists("album", squirrel.Eq{"id": 1})
|
||||||
sql, args, err := e.ToSql()
|
sql, args, err := e.ToSql()
|
||||||
Expect(sql).To(Equal("exists (select 1 from album where id = ?)"))
|
Expect(sql).To(Equal("exists (select 1 from album where id = ?)"))
|
||||||
Expect(args).To(Equal([]interface{}{1}))
|
Expect(args).To(ConsistOf(1))
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -74,4 +75,14 @@ var _ = Describe("Helpers", func() {
|
|||||||
Expect(getMostFrequentMbzID(context.TODO(), "1 2 3 4 2", "", "")).To(Equal("2"))
|
Expect(getMostFrequentMbzID(context.TODO(), "1 2 3 4 2", "", "")).To(Equal("2"))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Describe("getGenres", func() {
|
||||||
|
It("returns unique genres", func() {
|
||||||
|
expected := model.Genres{{ID: "1"}, {ID: "2"}, {ID: "3"}, {ID: "5"}, {ID: "4"}}
|
||||||
|
Expect(getGenres("1 2 3 5 3 2 4 ")).To(Equal(expected))
|
||||||
|
})
|
||||||
|
It("returns empty list when there are no genres", func() {
|
||||||
|
Expect(getGenres("")).To(BeEmpty())
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
"github.com/navidrome/navidrome/conf"
|
"github.com/navidrome/navidrome/conf"
|
||||||
"github.com/navidrome/navidrome/db"
|
"github.com/navidrome/navidrome/db"
|
||||||
|
|
||||||
"github.com/navidrome/navidrome/log"
|
"github.com/navidrome/navidrome/log"
|
||||||
"github.com/navidrome/navidrome/tests"
|
"github.com/navidrome/navidrome/tests"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
|
|||||||
Reference in New Issue
Block a user