mirror of
https://github.com/issadarkthing/gomu.git
synced 2025-04-25 13:48:49 +08:00
Fix tests
This commit is contained in:
parent
371c358847
commit
644c4fa695
@ -2,6 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/issadarkthing/gomu/player"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -30,11 +32,10 @@ func Test_NewProgress(t *testing.T) {
|
||||
|
||||
p := newPlayingBar()
|
||||
full := 100
|
||||
audio := AudioFile{
|
||||
path: "./test/rap/audio_test.mp3",
|
||||
}
|
||||
audio := new(player.AudioFile)
|
||||
audio.SetPath("./test/rap/audio_test.mp3")
|
||||
|
||||
p.newProgress(&audio, full)
|
||||
p.newProgress(audio, full)
|
||||
|
||||
if p.full != int32(full) {
|
||||
t.Errorf("Expected %d; got %d", full, p.full)
|
||||
|
@ -34,10 +34,9 @@ func prepareTest() *Gomu {
|
||||
}
|
||||
|
||||
root := tview.NewTreeNode("music")
|
||||
rootAudioFile := &AudioFile{
|
||||
name: root.GetText(),
|
||||
path: rootDir,
|
||||
}
|
||||
rootAudioFile := new(player.AudioFile)
|
||||
rootAudioFile.SetName(root.GetText())
|
||||
rootAudioFile.SetPath(rootDir)
|
||||
|
||||
root.SetReference(rootAudioFile)
|
||||
populate(root, rootDir, false)
|
||||
@ -86,10 +85,9 @@ func TestPopulate(t *testing.T) {
|
||||
|
||||
root := tview.NewTreeNode(path.Base(rootDir))
|
||||
|
||||
root.SetReference(&AudioFile{
|
||||
name: "Music",
|
||||
isAudioFile: false,
|
||||
})
|
||||
rootAudioFile := new(player.AudioFile)
|
||||
rootAudioFile.SetName("Music")
|
||||
rootAudioFile.SetIsAudioFile(false)
|
||||
|
||||
populate(root, rootDir, false)
|
||||
gotItems := 0
|
||||
@ -114,7 +112,7 @@ func TestAddAllToQueue(t *testing.T) {
|
||||
|
||||
gomu.playlist.GetRoot().Walk(func(node, parent *tview.TreeNode) bool {
|
||||
|
||||
if node.GetReference().(*AudioFile).name == "rap" {
|
||||
if node.GetReference().(*player.AudioFile).Name() == "rap" {
|
||||
gomu.playlist.addAllToQueue(node)
|
||||
}
|
||||
|
||||
@ -125,13 +123,13 @@ func TestAddAllToQueue(t *testing.T) {
|
||||
|
||||
for i, song := range songs {
|
||||
|
||||
audioFile := song.GetReference().(*AudioFile)
|
||||
audioFile := song.GetReference().(*player.AudioFile)
|
||||
|
||||
// strips the path of the song in the queue
|
||||
s := filepath.Base(queue[i])
|
||||
|
||||
if audioFile.name != s {
|
||||
t.Errorf("Expected \"%s\", got \"%s\"", audioFile.name, s)
|
||||
if audioFile.Name() != s {
|
||||
t.Errorf("Expected \"%s\", got \"%s\"", audioFile.Name(), s)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/issadarkthing/gomu/player"
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
@ -137,13 +138,13 @@ func TestEnqueue(t *testing.T) {
|
||||
|
||||
gomu = prepareTest()
|
||||
|
||||
var audioFiles []*AudioFile
|
||||
var audioFiles []*player.AudioFile
|
||||
|
||||
gomu.playlist.GetRoot().Walk(func(node, parent *tview.TreeNode) bool {
|
||||
gomu.playlist.GetRoot().Walk(func(node, _ *tview.TreeNode) bool {
|
||||
|
||||
audioFile := node.GetReference().(*AudioFile)
|
||||
audioFile := node.GetReference().(*player.AudioFile)
|
||||
|
||||
if audioFile.isAudioFile {
|
||||
if audioFile.IsAudioFile() {
|
||||
audioFiles = append(audioFiles, audioFile)
|
||||
return false
|
||||
}
|
||||
@ -159,8 +160,8 @@ func TestEnqueue(t *testing.T) {
|
||||
|
||||
for i, audioFile := range audioFiles {
|
||||
|
||||
if queue[i] != audioFile.path {
|
||||
t.Errorf("Invalid path; expected %s got %s", audioFile.path, queue[i])
|
||||
if queue[i] != audioFile.Path() {
|
||||
t.Errorf("Invalid path; expected %s got %s", audioFile.Path(), queue[i])
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user