audio: increase test coverage

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram 2017-04-06 09:50:01 +02:00
parent d63e5b3d9b
commit a2d76749ca
2 changed files with 16 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package audio
import ( import (
"os/exec" "os/exec"
"strings"
"testing" "testing"
"gobot.io/x/gobot" "gobot.io/x/gobot"
@ -18,6 +19,13 @@ func TestAudioAdaptor(t *testing.T) {
gobottest.Assert(t, a.Finalize(), nil) gobottest.Assert(t, a.Finalize(), nil)
} }
func TestAudioAdaptorName(t *testing.T) {
a := NewAdaptor()
gobottest.Assert(t, strings.HasPrefix(a.Name(), "Audio"), true)
a.SetName("NewName")
gobottest.Assert(t, a.Name(), "NewName")
}
func TestAudioAdaptorCommandsWav(t *testing.T) { func TestAudioAdaptorCommandsWav(t *testing.T) {
cmd, _ := CommandName("whatever.wav") cmd, _ := CommandName("whatever.wav")
gobottest.Assert(t, cmd, "aplay") gobottest.Assert(t, cmd, "aplay")

View File

@ -4,6 +4,7 @@ package audio
import ( import (
"os/exec" "os/exec"
"strings"
"testing" "testing"
"gobot.io/x/gobot" "gobot.io/x/gobot"
@ -24,6 +25,13 @@ func TestAudioDriver(t *testing.T) {
gobottest.Assert(t, d.Halt(), nil) gobottest.Assert(t, d.Halt(), nil)
} }
func TestAudioDriverName(t *testing.T) {
d := NewDriver(NewAdaptor(), "")
gobottest.Assert(t, strings.HasPrefix(d.Name(), "Audio"), true)
d.SetName("NewName")
gobottest.Assert(t, d.Name(), "NewName")
}
func TestAudioDriverSoundWithNoFilename(t *testing.T) { func TestAudioDriverSoundWithNoFilename(t *testing.T) {
d := NewDriver(NewAdaptor(), "") d := NewDriver(NewAdaptor(), "")