From c111636c32724c6e93b6736cef9070917764fb76 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Tue, 24 May 2016 18:49:58 -0700 Subject: [PATCH] [audio] Add yet additional test coverage for audio adaptor Signed-off-by: deadprogram --- platforms/audio/audio_adaptor.go | 2 +- platforms/audio/audio_adaptor_test.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/platforms/audio/audio_adaptor.go b/platforms/audio/audio_adaptor.go index 82883585..d278932e 100644 --- a/platforms/audio/audio_adaptor.go +++ b/platforms/audio/audio_adaptor.go @@ -33,7 +33,7 @@ func (a *AudioAdaptor) Sound(fileName string) []error { var errorsList []error if fileName == "" { - log.Println("Require filename for audio file.") + log.Println("Requires filename for audio file.") errorsList = append(errorsList, errors.New("Requires filename for audio file.")) return errorsList } diff --git a/platforms/audio/audio_adaptor_test.go b/platforms/audio/audio_adaptor_test.go index 41679533..5740374a 100644 --- a/platforms/audio/audio_adaptor_test.go +++ b/platforms/audio/audio_adaptor_test.go @@ -32,3 +32,17 @@ func TestAudioAdaptorCommandsUnknown(t *testing.T) { gobottest.Refute(t, cmd, "mpg123") gobottest.Assert(t, err.Error(), "Unknown filetype for audio file.") } + +func TestAudioAdaptorSoundWithNoFilename(t *testing.T) { + a := NewAudioAdaptor("tester") + + errors := a.Sound("") + gobottest.Assert(t, errors[0].Error(), "Requires filename for audio file.") +} + +func TestAudioAdaptorSoundWithNonexistingFilename(t *testing.T) { + a := NewAudioAdaptor("tester") + + errors := a.Sound("doesnotexist.mp3") + gobottest.Assert(t, errors[0].Error(), "stat doesnotexist.mp3: no such file or directory") +}