mirror of
https://github.com/onyx-and-iris/gobs-cli.git
synced 2025-08-05 11:31:45 +00:00
allow skip group tests
enable replay buffer in test setup() create Desktop Audio input if it doesn't exist.
This commit is contained in:
parent
c6406888a9
commit
040ece840c
@ -2,11 +2,20 @@ package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func skipIfSkipGroupTests(t *testing.T) {
|
||||
if os.Getenv("GOBS_TEST_SKIP_GROUP_TESTS") != "" {
|
||||
t.Skip("Skipping group tests due to GOBS_TEST_SKIP_GROUP_TESTS environment variable")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGroupList(t *testing.T) {
|
||||
skipIfSkipGroupTests(t)
|
||||
|
||||
client, disconnect := getClient(t)
|
||||
defer disconnect()
|
||||
|
||||
@ -26,6 +35,8 @@ func TestGroupList(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGroupShow(t *testing.T) {
|
||||
skipIfSkipGroupTests(t)
|
||||
|
||||
client, disconnect := getClient(t)
|
||||
defer disconnect()
|
||||
|
||||
@ -46,6 +57,8 @@ func TestGroupShow(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGroupToggle(t *testing.T) {
|
||||
skipIfSkipGroupTests(t)
|
||||
|
||||
client, disconnect := getClient(t)
|
||||
defer disconnect()
|
||||
|
||||
@ -87,6 +100,8 @@ func TestGroupToggle(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGroupStatus(t *testing.T) {
|
||||
skipIfSkipGroupTests(t)
|
||||
|
||||
client, disconnect := getClient(t)
|
||||
defer disconnect()
|
||||
|
||||
|
@ -22,9 +22,8 @@ func TestInputList(t *testing.T) {
|
||||
expectedInputs := []string{
|
||||
"Desktop Audio",
|
||||
"Mic/Aux",
|
||||
"Colour Source",
|
||||
"Colour Source 2",
|
||||
"Colour Source 3",
|
||||
"gobs-test-input",
|
||||
"gobs-test-input-2",
|
||||
}
|
||||
output := out.String()
|
||||
for _, input := range expectedInputs {
|
||||
@ -52,9 +51,8 @@ func TestInputListFilterInput(t *testing.T) {
|
||||
}
|
||||
expectedFilteredOut := []string{
|
||||
"Desktop Audio",
|
||||
"Colour Source",
|
||||
"Colour Source 2",
|
||||
"Colour Source 3",
|
||||
"gobs-test-input",
|
||||
"gobs-test-input-2",
|
||||
}
|
||||
for _, input := range expectedInputs {
|
||||
if !strings.Contains(out.String(), input) {
|
||||
@ -86,9 +84,8 @@ func TestInputListFilterOutput(t *testing.T) {
|
||||
}
|
||||
expectedFilteredOut := []string{
|
||||
"Mic/Aux",
|
||||
"Colour Source",
|
||||
"Colour Source 2",
|
||||
"Colour Source 3",
|
||||
"gobs-test-input",
|
||||
"gobs-test-input-2",
|
||||
}
|
||||
for _, input := range expectedInputs {
|
||||
if !strings.Contains(out.String(), input) {
|
||||
@ -116,9 +113,8 @@ func TestInputListFilterColour(t *testing.T) {
|
||||
}
|
||||
|
||||
expectedInputs := []string{
|
||||
"Colour Source",
|
||||
"Colour Source 2",
|
||||
"Colour Source 3",
|
||||
"gobs-test-input",
|
||||
"gobs-test-input-2",
|
||||
}
|
||||
for _, input := range expectedInputs {
|
||||
if !strings.Contains(out.String(), input) {
|
||||
|
29
main_test.go
29
main_test.go
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/andreykaipov/goobs"
|
||||
"github.com/andreykaipov/goobs/api/requests/config"
|
||||
@ -55,6 +56,22 @@ func TestMain(m *testing.M) {
|
||||
}
|
||||
|
||||
func setup(client *goobs.Client) {
|
||||
client.Config.CreateProfile(config.NewCreateProfileParams().
|
||||
WithProfileName("gobs-test-profile"))
|
||||
time.Sleep(2 * time.Second) // wait for profile creation to propagate
|
||||
client.Config.SetProfileParameter(config.NewSetProfileParameterParams().
|
||||
WithParameterCategory("SimpleOutput").
|
||||
WithParameterName("RecRB").
|
||||
WithParameterValue("true"))
|
||||
client.Config.SetProfileParameter(config.NewSetProfileParameterParams().
|
||||
WithParameterCategory("AdvOut").
|
||||
WithParameterName("RecRB").
|
||||
WithParameterValue("true"))
|
||||
client.Config.SetCurrentProfile(config.NewSetCurrentProfileParams().
|
||||
WithProfileName("Untitled"))
|
||||
client.Config.SetCurrentProfile(config.NewSetCurrentProfileParams().
|
||||
WithProfileName("gobs-test-profile"))
|
||||
|
||||
client.Config.SetStreamServiceSettings(config.NewSetStreamServiceSettingsParams().
|
||||
WithStreamServiceType("rtmp_common").
|
||||
WithStreamServiceSettings(&typedefs.StreamServiceSettings{
|
||||
@ -90,6 +107,15 @@ func setup(client *goobs.Client) {
|
||||
}).
|
||||
WithSceneItemEnabled(true))
|
||||
|
||||
// ensure Desktop Audio input is created
|
||||
client.Inputs.CreateInput(inputs.NewCreateInputParams().
|
||||
WithSceneName("gobs-test").
|
||||
WithInputName("Desktop Audio").
|
||||
WithInputKind("wasapi_output_capture").
|
||||
WithInputSettings(map[string]any{
|
||||
"device_id": "default",
|
||||
}))
|
||||
|
||||
// Create source filter on an audio input
|
||||
client.Filters.CreateSourceFilter(filters.NewCreateSourceFilterParams().
|
||||
WithSourceName("Mic/Aux").
|
||||
@ -115,6 +141,9 @@ func setup(client *goobs.Client) {
|
||||
}
|
||||
|
||||
func teardown(client *goobs.Client) {
|
||||
client.Config.RemoveProfile(config.NewRemoveProfileParams().
|
||||
WithProfileName("gobs-test-profile"))
|
||||
|
||||
client.Filters.RemoveSourceFilter(filters.NewRemoveSourceFilterParams().
|
||||
WithSourceName("Mic/Aux").
|
||||
WithFilterName("test_filter"))
|
||||
|
@ -2,11 +2,20 @@ package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func skipIfSkipReplayBufferTests(t *testing.T) {
|
||||
if os.Getenv("GOBS_TEST_SKIP_REPLAYBUFFER_TESTS") != "" {
|
||||
t.Skip("Skipping replay buffer tests due to GOBS_TEST_SKIP_REPLAYBUFFER_TESTS environment variable")
|
||||
}
|
||||
}
|
||||
|
||||
func TestReplayBufferStart(t *testing.T) {
|
||||
skipIfSkipReplayBufferTests(t)
|
||||
|
||||
client, disconnect := getClient(t)
|
||||
defer disconnect()
|
||||
|
||||
@ -24,6 +33,8 @@ func TestReplayBufferStart(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReplayBufferStop(t *testing.T) {
|
||||
skipIfSkipReplayBufferTests(t)
|
||||
|
||||
client, disconnect := getClient(t)
|
||||
defer disconnect()
|
||||
|
||||
@ -41,6 +52,8 @@ func TestReplayBufferStop(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReplayBufferToggle(t *testing.T) {
|
||||
skipIfSkipReplayBufferTests(t)
|
||||
|
||||
client, disconnect := getClient(t)
|
||||
defer disconnect()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user