forked from swaggo/swag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema_test.go
46 lines (40 loc) · 1.06 KB
/
schema_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
45
46
package swag
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestValidDataType(t *testing.T) {
assert.NotPanics(t, func() {
CheckSchemaType("string")
})
assert.NotPanics(t, func() {
CheckSchemaType("number")
})
assert.NotPanics(t, func() {
CheckSchemaType("integer")
})
assert.NotPanics(t, func() {
CheckSchemaType("boolean")
})
assert.NotPanics(t, func() {
CheckSchemaType("array")
})
assert.NotPanics(t, func() {
CheckSchemaType("object")
})
assert.Panics(t, func() {
CheckSchemaType("oops")
})
}
func TestTransToValidSchemeType(t *testing.T) {
assert.Equal(t, TransToValidSchemeType("uint"), "integer")
assert.Equal(t, TransToValidSchemeType("uint32"), "integer")
assert.Equal(t, TransToValidSchemeType("uint64"), "integer")
assert.Equal(t, TransToValidSchemeType("float32"), "number")
assert.Equal(t, TransToValidSchemeType("bool"), "boolean")
assert.Equal(t, TransToValidSchemeType("string"), "string")
// should accept any type, due to user defined types
assert.NotPanics(t, func() {
TransToValidSchemeType("oops")
})
}