Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed Jul 20, 2021
1 parent 58ee4c6 commit 69f71be
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 2 additions & 4 deletions persistence/genre_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ package persistence
import (
"context"

"github.com/navidrome/navidrome/log"

"github.com/deluan/rest"

. "github.com/Masterminds/squirrel"
"github.com/astaxie/beego/orm"
"github.com/deluan/rest"
"github.com/navidrome/navidrome/log"
"github.com/navidrome/navidrome/model"
)

Expand Down
13 changes: 12 additions & 1 deletion persistence/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"

"github.com/Masterminds/squirrel"
"github.com/navidrome/navidrome/model"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
Expand Down Expand Up @@ -58,7 +59,7 @@ var _ = Describe("Helpers", func() {
e := exists("album", squirrel.Eq{"id": 1})
sql, args, err := e.ToSql()
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())
})
})
Expand All @@ -74,4 +75,14 @@ var _ = Describe("Helpers", func() {
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())
})
})
})
1 change: 0 additions & 1 deletion scanner/scanner_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/astaxie/beego/orm"
"github.com/navidrome/navidrome/conf"
"github.com/navidrome/navidrome/db"

"github.com/navidrome/navidrome/log"
"github.com/navidrome/navidrome/tests"
. "github.com/onsi/ginkgo"
Expand Down

0 comments on commit 69f71be

Please sign in to comment.