mirror of
https://github.com/onyx-and-iris/gobs-cli.git
synced 2025-06-09 21:20:34 +01:00
add filter/input/version tests
This commit is contained in:
parent
f58b2dfeab
commit
3deb03cf32
76
filter_test.go
Normal file
76
filter_test.go
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
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(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
140
input_test.go
Normal file
140
input_test.go
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestInputList(t *testing.T) {
|
||||||
|
client, disconnect := getClient(t)
|
||||||
|
defer disconnect()
|
||||||
|
|
||||||
|
var out bytes.Buffer
|
||||||
|
context := &context{
|
||||||
|
Client: client,
|
||||||
|
Out: &out,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd := &InputListCmd{}
|
||||||
|
err := cmd.Run(context)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to list inputs: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedInputs := []string{
|
||||||
|
"Desktop Audio",
|
||||||
|
"Mic/Aux",
|
||||||
|
"Colour Source",
|
||||||
|
"Colour Source 2",
|
||||||
|
"Colour Source 3",
|
||||||
|
}
|
||||||
|
output := out.String()
|
||||||
|
for _, input := range expectedInputs {
|
||||||
|
if !strings.Contains(output, input) {
|
||||||
|
t.Fatalf("Expected output to contain '%s', got '%s'", input, output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestInputListFilterInput(t *testing.T) {
|
||||||
|
client, disconnect := getClient(t)
|
||||||
|
defer disconnect()
|
||||||
|
|
||||||
|
var out bytes.Buffer
|
||||||
|
context := &context{
|
||||||
|
Client: client,
|
||||||
|
Out: &out,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd := &InputListCmd{Input: true}
|
||||||
|
err := cmd.Run(context)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to list inputs with filter: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedInputs := []string{
|
||||||
|
"Mic/Aux",
|
||||||
|
}
|
||||||
|
expectedFilteredOut := []string{
|
||||||
|
"Desktop Audio",
|
||||||
|
"Colour Source",
|
||||||
|
"Colour Source 2",
|
||||||
|
"Colour Source 3",
|
||||||
|
}
|
||||||
|
for _, input := range expectedInputs {
|
||||||
|
if !strings.Contains(out.String(), input) {
|
||||||
|
t.Fatalf("Expected output to contain '%s', got '%s'", input, out.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, filteredOut := range expectedFilteredOut {
|
||||||
|
if strings.Contains(out.String(), filteredOut) {
|
||||||
|
t.Fatalf("Expected output to NOT contain '%s', got '%s'", filteredOut, out.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestInputListFilterOutput(t *testing.T) {
|
||||||
|
client, disconnect := getClient(t)
|
||||||
|
defer disconnect()
|
||||||
|
|
||||||
|
var out bytes.Buffer
|
||||||
|
context := &context{
|
||||||
|
Client: client,
|
||||||
|
Out: &out,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd := &InputListCmd{Output: true}
|
||||||
|
err := cmd.Run(context)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to list outputs with filter: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedInputs := []string{
|
||||||
|
"Desktop Audio",
|
||||||
|
}
|
||||||
|
expectedFilteredOut := []string{
|
||||||
|
"Mic/Aux",
|
||||||
|
"Colour Source",
|
||||||
|
"Colour Source 2",
|
||||||
|
"Colour Source 3",
|
||||||
|
}
|
||||||
|
for _, input := range expectedInputs {
|
||||||
|
if !strings.Contains(out.String(), input) {
|
||||||
|
t.Fatalf("Expected output to contain '%s', got '%s'", input, out.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, filteredOut := range expectedFilteredOut {
|
||||||
|
if strings.Contains(out.String(), filteredOut) {
|
||||||
|
t.Fatalf("Expected output to NOT contain '%s', got '%s'", filteredOut, out.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestInputListFilterColour(t *testing.T) {
|
||||||
|
client, disconnect := getClient(t)
|
||||||
|
defer disconnect()
|
||||||
|
|
||||||
|
var out bytes.Buffer
|
||||||
|
context := &context{
|
||||||
|
Client: client,
|
||||||
|
Out: &out,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd := &InputListCmd{Colour: true}
|
||||||
|
err := cmd.Run(context)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to list colour inputs with filter: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedInputs := []string{
|
||||||
|
"Colour Source",
|
||||||
|
"Colour Source 2",
|
||||||
|
"Colour Source 3",
|
||||||
|
}
|
||||||
|
for _, input := range expectedInputs {
|
||||||
|
if !strings.Contains(out.String(), input) {
|
||||||
|
t.Fatalf("Expected output to contain '%s', got '%s'", input, out.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
30
version_test.go
Normal file
30
version_test.go
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestVersion(t *testing.T) {
|
||||||
|
client, disconnect := getClient(t)
|
||||||
|
defer disconnect()
|
||||||
|
|
||||||
|
var out bytes.Buffer
|
||||||
|
context := &context{
|
||||||
|
Client: client,
|
||||||
|
Out: &out,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd := &VersionCmd{}
|
||||||
|
err := cmd.Run(context)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to get version: %v", err)
|
||||||
|
}
|
||||||
|
if !strings.Contains(out.String(), "OBS Client Version:") {
|
||||||
|
t.Fatalf("Expected output to contain 'OBS Client Version:', got '%s'", out.String())
|
||||||
|
}
|
||||||
|
if !strings.Contains(out.String(), "with Websocket Version:") {
|
||||||
|
t.Fatalf("Expected output to contain 'with Websocket Version:', got '%s'", out.String())
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user