mirror of
https://github.com/onyx-and-iris/gobs-cli.git
synced 2026-04-17 22:53:36 +00:00
71 lines
1.6 KiB
Go
71 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestFilterList(t *testing.T) {
|
|
client, disconnect := getClient(t)
|
|
defer disconnect()
|
|
|
|
var out bytes.Buffer
|
|
context := newContext(client, &out, StyleConfig{})
|
|
|
|
cmd := &FilterListCmd{
|
|
SourceName: "Mic/Aux",
|
|
}
|
|
err := cmd.Run(context)
|
|
if err != nil {
|
|
t.Fatalf("Failed to list filters: %v", err)
|
|
}
|
|
if !strings.Contains(out.String(), "test_filter") {
|
|
t.Fatalf("Expected output to contain 'test_filter', got '%s'", out.String())
|
|
}
|
|
}
|
|
|
|
func TestFilterListScene(t *testing.T) {
|
|
client, disconnect := getClient(t)
|
|
defer disconnect()
|
|
|
|
var out bytes.Buffer
|
|
context := newContext(client, &out, StyleConfig{})
|
|
|
|
cmd := &FilterListCmd{
|
|
SourceName: "gobs-test-scene",
|
|
}
|
|
err := cmd.Run(context)
|
|
if err != nil {
|
|
t.Fatalf("Failed to list filters in scene: %v", err)
|
|
}
|
|
if !strings.Contains(out.String(), "test_filter") {
|
|
t.Fatalf("Expected output to contain 'test_filter', got '%s'", out.String())
|
|
}
|
|
}
|
|
|
|
func TestFilterListEmpty(t *testing.T) {
|
|
client, disconnect := getClient(t)
|
|
defer disconnect()
|
|
|
|
var out bytes.Buffer
|
|
context := newContext(client, &out, StyleConfig{})
|
|
|
|
cmd := &FilterListCmd{
|
|
SourceName: "NonExistentSource",
|
|
}
|
|
err := cmd.Run(context)
|
|
if err == nil {
|
|
t.Fatal("Expected error for non-existent source, but got none")
|
|
}
|
|
if !strings.Contains(
|
|
err.Error(),
|
|
"No source was found by the name of `NonExistentSource` within the canvas `Main`.",
|
|
) {
|
|
t.Fatalf(
|
|
"Expected error to contain 'No source was found by the name of `NonExistentSource` within the canvas `Main`.', got '%s'",
|
|
err.Error(),
|
|
)
|
|
}
|
|
}
|