forked from danielgtaylor/huma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
registry_test.go
55 lines (45 loc) · 1.25 KB
/
registry_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
47
48
49
50
51
52
53
54
55
package huma
import (
"net/url"
"reflect"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
type Output[T any] struct{}
type Embedded[P any] struct{}
type EmbeddedTwo[P, V any] struct{}
type S struct{}
type ü struct{}
type MP4 struct{}
func TestDefaultSchemaNamer(t *testing.T) {
type Renamed Output[*[]Embedded[time.Time]]
for _, example := range []struct {
typ any
name string
}{
{int(0), "Int"},
{int64(0), "Int64"},
{S{}, "S"},
{time.Time{}, "Time"},
{Output[int]{}, "OutputInt"},
{Output[*int]{}, "OutputInt"},
{Output[[]int]{}, "OutputListInt"},
{Output[[]*int]{}, "OutputListInt"},
{Output[[][]int]{}, "OutputListListInt"},
{Output[map[string]int]{}, "OutputMapStringInt"},
{Output[map[string][]*int]{}, "OutputMapStringListInt"},
{Output[S]{}, "OutputS"},
{Output[ü]{}, "OutputÜ"},
{Output[MP4]{}, "OutputMP4"},
{Output[Embedded[*time.Time]]{}, "OutputEmbeddedTime"},
{Output[*[]Embedded[time.Time]]{}, "OutputListEmbeddedTime"},
{Output[EmbeddedTwo[[]time.Time, **url.URL]]{}, "OutputEmbeddedTwoListTimeURL"},
{Renamed{}, "Renamed"},
} {
t.Run(example.name, func(t *testing.T) {
name := DefaultSchemaNamer(reflect.TypeOf(example.typ), "hint")
assert.Equal(t, example.name, name)
})
}
}