-
Notifications
You must be signed in to change notification settings - Fork 2
/
tag_test.go
39 lines (32 loc) · 864 Bytes
/
tag_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
package mapper
import (
"testing"
"github.com/stretchr/testify/require"
)
/***************************
@author: tiansheng.ren
@date: 2022/11/2
@desc:
***************************/
func TestCopyTag(t *testing.T) {
tag := newCopyTag("id")
require.Equal(t, "id", tag.Name())
tag = newCopyTag("")
require.Equal(t, "", tag.Name())
}
func TestJSONTag(t *testing.T) {
tag := newJSONTag("id")
require.Equal(t, "id", tag.Name())
tag = newJSONTag("id,copy=copy_id")
require.Equal(t, "copy_id", tag.Name())
tag = newJSONTag("")
require.Equal(t, "", tag.Name())
}
func TestGormTag(t *testing.T) {
tag := newGormTag("primary_key;column:id;type:int(10);not null")
require.Equal(t, "id", tag.Name())
tag = newGormTag("column:id;type:int(10);not null")
require.Equal(t, "id", tag.Name())
tag = newGormTag("")
require.Equal(t, "", tag.Name())
}