-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmedia_type_test.go
44 lines (31 loc) · 972 Bytes
/
media_type_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
44
package oas
import (
"testing"
)
func TestMediaType(t *testing.T) {
g := NewCaseGroup("MediaType")
g.It("empty", `{}`, MediaType{})
g.It("with schema", `{"schema":{"type":"string"}}`, MediaType{
MediaTypeObject: MediaTypeObject{
Schema: String(),
},
})
g.It("with schema and example", `{"schema":{"type":"string"},"example":"some string","examples":{"some":{"value":"string","externalValue":"string"}}}`, func() *MediaType {
m := NewMediaTypeWithSchema(String())
m.Example = "some string"
ex := NewExample()
ex.Value = "string"
ex.ExternalValue = "string"
m.AddExample("some", ex)
return m
}())
g.It("with encoding", `{"schema":{"type":"string"},"encoding":{"utf-8":{"contentType":"application/json","style":"simple"}}}`, func() *MediaType {
m := NewMediaTypeWithSchema(String())
e := NewEncoding()
e.ContentType = "application/json"
e.Style = ParameterStyleSimple
m.AddEncoding("utf-8", e)
return m
}())
g.Run(t)
}