forked from KKKIIO/swag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema_test.go
30 lines (24 loc) · 942 Bytes
/
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
package swag
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestValidDataType(t *testing.T) {
assert.NoError(t, CheckSchemaType("string"))
assert.NoError(t, CheckSchemaType("number"))
assert.NoError(t, CheckSchemaType("integer"))
assert.NoError(t, CheckSchemaType("boolean"))
assert.NoError(t, CheckSchemaType("array"))
assert.NoError(t, CheckSchemaType("object"))
assert.Error(t, 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
TransToValidSchemeType("oops")
}