mirror of
https://github.com/onyx-and-iris/gobs-cli.git
synced 2025-06-09 21:20:34 +01:00
77 lines
1.5 KiB
Go
77 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestFilterList(t *testing.T) {
|
|
client, disconnect := getClient(t)
|
|
defer disconnect()
|
|
|
|
var out bytes.Buffer
|
|
context := &context{
|
|
Client: client,
|
|
Out: &out,
|
|
}
|
|
|
|
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 := &context{
|
|
Client: client,
|
|
Out: &out,
|
|
}
|
|
|
|
cmd := &FilterListCmd{
|
|
SourceName: "gobs-test",
|
|
}
|
|
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 := &context{
|
|
Client: client,
|
|
Out: &out,
|
|
}
|
|
|
|
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`.") {
|
|
t.Fatalf(
|
|
"Expected error to contain 'No source was found by the name of `NonExistentSource`.', got '%s'",
|
|
err.Error(),
|
|
)
|
|
}
|
|
}
|