Fix Windows test

This commit is contained in:
Deluan
2020-01-18 01:56:17 -05:00
parent ccbdf688ea
commit 8ae4fdd5b2
2 changed files with 16 additions and 5 deletions
+6 -1
View File
@@ -1,6 +1,9 @@
package persistence package persistence
import ( import (
"os"
"path/filepath"
"github.com/cloudsonic/sonic-server/model" "github.com/cloudsonic/sonic-server/model"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
@@ -15,7 +18,9 @@ var _ = Describe("MediaFileRepository", func() {
Describe("FindByPath", func() { Describe("FindByPath", func() {
It("returns all records from a given ArtistID", func() { It("returns all records from a given ArtistID", func() {
Expect(repo.FindByPath("/beatles/1")).To(Equal(model.MediaFiles{ path := string(os.PathSeparator) + filepath.Join("beatles", "1")
println("Searching path", path) // TODO Remove
Expect(repo.FindByPath(path)).To(Equal(model.MediaFiles{
songComeTogether, songComeTogether,
})) }))
}) })
+10 -4
View File
@@ -1,6 +1,8 @@
package persistence package persistence
import ( import (
"os"
"strings"
"testing" "testing"
"github.com/cloudsonic/sonic-server/conf" "github.com/cloudsonic/sonic-server/conf"
@@ -34,10 +36,10 @@ var testAlbums = model.Albums{
albumRadioactivity, albumRadioactivity,
} }
var songDayInALife = model.MediaFile{ID: "1", Title: "A Day In A Life", ArtistID: "3", AlbumID: "1", Genre: "Rock", Path: "/beatles/1/sgt/a day.mp3"} var songDayInALife = model.MediaFile{ID: "1", Title: "A Day In A Life", ArtistID: "3", AlbumID: "1", Genre: "Rock", Path: P("/beatles/1/sgt/a day.mp3")}
var songComeTogether = model.MediaFile{ID: "2", Title: "Come Together", ArtistID: "3", AlbumID: "2", Genre: "Rock", Path: "/beatles/1/come together.mp3"} var songComeTogether = model.MediaFile{ID: "2", Title: "Come Together", ArtistID: "3", AlbumID: "2", Genre: "Rock", Path: P("/beatles/1/come together.mp3")}
var songRadioactivity = model.MediaFile{ID: "3", Title: "Radioactivity", ArtistID: "2", AlbumID: "3", Genre: "Electronic", Path: "/kraft/radio/radio.mp3"} var songRadioactivity = model.MediaFile{ID: "3", Title: "Radioactivity", ArtistID: "2", AlbumID: "3", Genre: "Electronic", Path: P("/kraft/radio/radio.mp3")}
var songAntenna = model.MediaFile{ID: "4", Title: "Antenna", ArtistID: "2", AlbumID: "3", Genre: "Electronic", Path: "/kraft/radio/antenna.mp3"} var songAntenna = model.MediaFile{ID: "4", Title: "Antenna", ArtistID: "2", AlbumID: "3", Genre: "Electronic", Path: P("/kraft/radio/antenna.mp3")}
var testSongs = model.MediaFiles{ var testSongs = model.MediaFiles{
songDayInALife, songDayInALife,
songComeTogether, songComeTogether,
@@ -45,6 +47,10 @@ var testSongs = model.MediaFiles{
songAntenna, songAntenna,
} }
func P(path string) string {
return strings.ReplaceAll(path, "/", string(os.PathSeparator))
}
var _ = Describe("Initialize test DB", func() { var _ = Describe("Initialize test DB", func() {
BeforeSuite(func() { BeforeSuite(func() {
//log.SetLevel(log.LevelTrace) //log.SetLevel(log.LevelTrace)