-
-
Notifications
You must be signed in to change notification settings - Fork 134
/
Copy pathpostgres_test.go
57 lines (55 loc) · 1.23 KB
/
postgres_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
56
57
package postgres
import (
"testing"
"gorm.io/gorm/schema"
)
func Test_DataTypeOf(t *testing.T) {
type fields struct {
Config *Config
}
type args struct {
field *schema.Field
}
tests := []struct {
name string
fields fields
args args
want string
} {
{
name: "it should return boolean",
args: args{field: &schema.Field{DataType: schema.Bool}},
want: "boolean",
},
{
name: "it should return text -1",
args: args{field: &schema.Field{DataType: schema.String, Size: -1}},
want: "text",
},
{
name: "it should return text > 10485760",
args: args{field: &schema.Field{DataType: schema.String, Size: 12345678}},
want: "text",
},
{
name: "it should return varchar(100)",
args: args{field: &schema.Field{DataType: schema.String, Size: 100}},
want: "varchar(100)",
},
{
name: "it should return varchar(10485760)",
args: args{field: &schema.Field{DataType: schema.String, Size: 10485760}},
want: "varchar(10485760)",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
dialector := Dialector{
Config: tt.fields.Config,
}
if got := dialector.DataTypeOf(tt.args.field); got != tt.want {
t.Errorf("DataTypeOf() = %v, want %v", got, tt.want)
}
})
}
}