diff --git a/inst/tinytest/test_providers.R b/inst/tinytest/test_providers.R new file mode 100644 index 0000000..3767561 --- /dev/null +++ b/inst/tinytest/test_providers.R @@ -0,0 +1,24 @@ +# Test TTS provider configuration + +# tts_providers is a named list +expect_true(is.list(tts_providers)) +expect_true(length(tts_providers) > 0) + +# Expected providers exist +expect_true("OpenAI" %in% names(tts_providers)) +expect_true("ElevenLabs" %in% names(tts_providers)) + +# Each provider has expected structure +for (name in names(tts_providers)) { + p <- tts_providers[[name]] + expect_true(is.list(p), info = paste(name, "should be a list")) + expect_true("voices" %in% names(p) || is.null(p$voices), + info = paste(name, "should have voices field")) + expect_true("base_url" %in% names(p), + info = paste(name, "should have base_url")) +} + +# OpenAI has static voice list +expect_true(is.character(tts_providers[["OpenAI"]]$voices)) +expect_true("nova" %in% tts_providers[["OpenAI"]]$voices) +expect_true("alloy" %in% tts_providers[["OpenAI"]]$voices) diff --git a/inst/tinytest/test_speech_clone.R b/inst/tinytest/test_speech_clone.R new file mode 100644 index 0000000..95f7e28 --- /dev/null +++ b/inst/tinytest/test_speech_clone.R @@ -0,0 +1,37 @@ +# Test speech_clone() input validation + +# input must be non-empty character +expect_error( + speech_clone(NULL, voice_file = "x.wav"), + pattern = "non-empty character" +) +expect_error( + speech_clone("", voice_file = "x.wav"), + pattern = "non-empty character" +) +expect_error( + speech_clone(123, voice_file = "x.wav"), + pattern = "non-empty character" +) + +# voice_file must be a character string +expect_error( + speech_clone("hello", voice_file = NULL), + pattern = "character string" +) +expect_error( + speech_clone("hello", voice_file = 123), + pattern = "character string" +) + +# voice_file must exist +expect_error( + speech_clone("hello", voice_file = "nonexistent_xyz.wav"), + pattern = "not found" +) + +# backend must be valid +expect_error( + speech_clone("hello", voice_file = "x.wav", backend = "invalid"), + pattern = "arg" +) diff --git a/inst/tinytest/test_speech_design.R b/inst/tinytest/test_speech_design.R new file mode 100644 index 0000000..ea54f9d --- /dev/null +++ b/inst/tinytest/test_speech_design.R @@ -0,0 +1,21 @@ +# Test speech_design() input validation + +# input must be non-empty character +expect_error( + speech_design(NULL, voice_description = "warm voice"), + pattern = "non-empty character" +) +expect_error( + speech_design("", voice_description = "warm voice"), + pattern = "non-empty character" +) + +# voice_description must be non-empty character +expect_error( + speech_design("hello", voice_description = NULL), + pattern = "non-empty character" +) +expect_error( + speech_design("hello", voice_description = ""), + pattern = "non-empty character" +)