Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tramhao committed Apr 30, 2021
1 parent 371c358 commit 644c4fa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
9 changes: 5 additions & 4 deletions playingbar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package main

import (
"testing"

"github.com/issadarkthing/gomu/player"
)

const (
Expand Down Expand Up @@ -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)
Expand Down
22 changes: 10 additions & 12 deletions playlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
}

Expand All @@ -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)
}

}
Expand Down
13 changes: 7 additions & 6 deletions queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"testing"

"github.com/issadarkthing/gomu/player"
"github.com/rivo/tview"
)

Expand Down Expand Up @@ -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
}
Expand All @@ -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])
}
}

Expand Down

0 comments on commit 644c4fa

Please sign in to comment.