forked from External/mediamtx
parent
dd7d7c6c5d
commit
b3eaec50c1
3 changed files with 183 additions and 43 deletions
61
internal/servers/srt/streamid_test.go
Normal file
61
internal/servers/srt/streamid_test.go
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
package srt
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestStreamIDUnmarshal(t *testing.T) {
|
||||
for _, ca := range []struct {
|
||||
name string
|
||||
raw string
|
||||
dec streamID
|
||||
}{
|
||||
{
|
||||
"mediamtx syntax 1",
|
||||
"read:mypath",
|
||||
streamID{
|
||||
mode: streamIDModeRead,
|
||||
path: "mypath",
|
||||
},
|
||||
},
|
||||
{
|
||||
"mediamtx syntax 2",
|
||||
"publish:mypath:myquery",
|
||||
streamID{
|
||||
mode: streamIDModePublish,
|
||||
path: "mypath",
|
||||
query: "myquery",
|
||||
},
|
||||
},
|
||||
{
|
||||
"mediamtx syntax 3",
|
||||
"read:mypath:myuser:mypass:myquery",
|
||||
streamID{
|
||||
mode: streamIDModeRead,
|
||||
path: "mypath",
|
||||
user: "myuser",
|
||||
pass: "mypass",
|
||||
query: "myquery",
|
||||
},
|
||||
},
|
||||
{
|
||||
"standard syntax",
|
||||
"#!::u=johnny,t=file,m=publish,r=results.csv,s=mypass,h=myhost.com",
|
||||
streamID{
|
||||
mode: streamIDModePublish,
|
||||
path: "results.csv",
|
||||
user: "johnny",
|
||||
pass: "mypass",
|
||||
},
|
||||
},
|
||||
} {
|
||||
t.Run(ca.name, func(t *testing.T) {
|
||||
var streamID streamID
|
||||
err := streamID.unmarshal(ca.raw)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, ca.dec, streamID)
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue