mirror of
https://github.com/aler9/gortsplib
synced 2025-10-06 15:46:51 +08:00
move subfolders in pkg/
This commit is contained in:
68
pkg/headers/session_test.go
Normal file
68
pkg/headers/session_test.go
Normal file
@@ -0,0 +1,68 @@
|
||||
package headers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/aler9/gortsplib/pkg/base"
|
||||
)
|
||||
|
||||
var casesSession = []struct {
|
||||
name string
|
||||
vin base.HeaderValue
|
||||
vout base.HeaderValue
|
||||
h *Session
|
||||
}{
|
||||
{
|
||||
"base",
|
||||
base.HeaderValue{`A3eqwsafq3rFASqew`},
|
||||
base.HeaderValue{`A3eqwsafq3rFASqew`},
|
||||
&Session{
|
||||
Session: "A3eqwsafq3rFASqew",
|
||||
},
|
||||
},
|
||||
{
|
||||
"with timeout",
|
||||
base.HeaderValue{`A3eqwsafq3rFASqew;timeout=47`},
|
||||
base.HeaderValue{`A3eqwsafq3rFASqew;timeout=47`},
|
||||
&Session{
|
||||
Session: "A3eqwsafq3rFASqew",
|
||||
Timeout: func() *uint {
|
||||
v := uint(47)
|
||||
return &v
|
||||
}(),
|
||||
},
|
||||
},
|
||||
{
|
||||
"with timeout and space",
|
||||
base.HeaderValue{`A3eqwsafq3rFASqew; timeout=47`},
|
||||
base.HeaderValue{`A3eqwsafq3rFASqew;timeout=47`},
|
||||
&Session{
|
||||
Session: "A3eqwsafq3rFASqew",
|
||||
Timeout: func() *uint {
|
||||
v := uint(47)
|
||||
return &v
|
||||
}(),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func TestSessionRead(t *testing.T) {
|
||||
for _, c := range casesSession {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
req, err := ReadSession(c.vin)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, c.h, req)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSessionWrite(t *testing.T) {
|
||||
for _, c := range casesSession {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
req := c.h.Write()
|
||||
require.Equal(t, c.vout, req)
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user