forked from WEG-Technology/room
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbody_test.go
43 lines (33 loc) · 1020 Bytes
/
body_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package room
import (
"testing"
)
func TestJsonBody_Parse(t *testing.T) {
data := map[string]interface{}{"key": "value"}
body := NewJsonBodyParser(data).Parse()
if body == nil {
t.Error("Expected a non-nil buffer, but got nil")
}
// Optionally, you can check the content of the buffer or other expectations.
}
type testStruct struct {
Key string `url:"key"`
}
func TestFormURLEncodedBody_Parse(t *testing.T) {
data := testStruct{"value"}
body := NewFormURLEncodedBodyParser(data).Parse()
if body == nil {
t.Error("Expected a non-nil buffer, but got nil")
}
// Optionally, you can check the content of the buffer or other expectations.
}
func TestFormURLEncodedBody_Parse_Error(t *testing.T) {
// Test case where query.Values returns an error
data := map[string]interface{}{"key": make(chan int)} // invalid type to trigger an error
defer func() {
if r := recover(); r == nil {
t.Error("Expected a panic, but no panic occurred")
}
}()
_ = NewFormURLEncodedBodyParser(data).Parse()
}