base: improve tests

This commit is contained in:
aler9
2021-05-07 12:59:50 +02:00
parent e52fda806d
commit bec905ed9c
3 changed files with 28 additions and 4 deletions

View File

@@ -168,20 +168,25 @@ func TestRequestReadErrors(t *testing.T) {
"EOF", "EOF",
}, },
{ {
"missing url, protocol, eol", "missing url, protocol, r, n",
[]byte("GET"), []byte("GET"),
"EOF", "EOF",
}, },
{ {
"missing protocol, eol", "missing protocol, r, n",
[]byte("GET rtsp://testing123/test"), []byte("GET rtsp://testing123/test"),
"EOF", "EOF",
}, },
{ {
"missing eol", "missing r, n",
[]byte("GET rtsp://testing123/test RTSP/1.0"), []byte("GET rtsp://testing123/test RTSP/1.0"),
"EOF", "EOF",
}, },
{
"missing n",
[]byte("GET rtsp://testing123/test RTSP/1.0\r"),
"EOF",
},
{ {
"empty method", "empty method",
[]byte(" rtsp://testing123 RTSP/1.0\r\n"), []byte(" rtsp://testing123 RTSP/1.0\r\n"),
@@ -207,6 +212,16 @@ func TestRequestReadErrors(t *testing.T) {
[]byte("GET rtsp://testing123 RTSP/2.0\r\n"), []byte("GET rtsp://testing123 RTSP/2.0\r\n"),
"expected 'RTSP/1.0', got 'RTSP/2.0'", "expected 'RTSP/1.0', got 'RTSP/2.0'",
}, },
{
"invalid header",
[]byte("GET rtsp://testing123 RTSP/1.0\r\nTesting: val\r"),
"EOF",
},
{
"invalid body",
[]byte("GET rtsp://testing123 RTSP/1.0\r\nContent-Length: 17\r\n\r\n123"),
"unexpected EOF",
},
} { } {
t.Run(ca.name, func(t *testing.T) { t.Run(ca.name, func(t *testing.T) {
var req Request var req Request

View File

@@ -169,6 +169,16 @@ func TestResponseReadErrors(t *testing.T) {
[]byte("RTSP/1.0 200 \r\n"), []byte("RTSP/1.0 200 \r\n"),
"empty status message", "empty status message",
}, },
{
"invalid header",
[]byte("RTSP/1.0 200 OK\r\nTesting: val\r"),
"EOF",
},
{
"invalid body",
[]byte("RTSP/1.0 200 OK\r\nContent-Length: 17\r\n\r\n123"),
"unexpected EOF",
},
} { } {
t.Run(ca.name, func(t *testing.T) { t.Run(ca.name, func(t *testing.T) {
var res Response var res Response

View File

@@ -217,7 +217,6 @@ func (t *Track) ExtractDataAAC() ([]byte, error) {
if err != nil { if err != nil {
return nil, fmt.Errorf("invalid config (%v)", v) return nil, fmt.Errorf("invalid config (%v)", v)
} }
break
} }
} }