Skip to content

Commit

Permalink
Fix type-safety tests
Browse files Browse the repository at this point in the history
  • Loading branch information
System-Glitch committed Apr 5, 2023
1 parent 307a3d7 commit 0ac0b7b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
6 changes: 3 additions & 3 deletions filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestFilterScope(t *testing.T) {
schema := &schema.Schema{
DBNames: []string{"name"},
FieldsByDBName: map[string]*schema.Field{
"name": {Name: "Name", DBName: "name", DataType: schema.String},
"name": {Name: "Name", DBName: "name", GORMDataType: schema.String},
},
Table: "test_scope_models",
}
Expand Down Expand Up @@ -84,7 +84,7 @@ func TestFilterScopeBlacklisted(t *testing.T) {
schema := &schema.Schema{
DBNames: []string{"name"},
FieldsByDBName: map[string]*schema.Field{
"name": {Name: "Name"},
"name": {Name: "Name", GORMDataType: schema.String},
},
}

Expand Down Expand Up @@ -627,7 +627,7 @@ func TestFilterScopeWithUnsupportedDataType(t *testing.T) {
schema := &schema.Schema{
DBNames: []string{"name"},
FieldsByDBName: map[string]*schema.Field{
"name": {Name: "Name", DBName: "name", DataType: "CHARACTER VARYING(255)"},
"name": {Name: "Name", DBName: "name", GORMDataType: "custom", DataType: "CHARACTER VARYING(255)"},
},
Table: "test_scope_models",
}
Expand Down
18 changes: 9 additions & 9 deletions search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ func TestSearchScope(t *testing.T) {

schema := &schema.Schema{
FieldsByDBName: map[string]*schema.Field{
"name": {Name: "Name", DBName: "name", DataType: schema.String},
"email": {Name: "Email", DBName: "email", DataType: schema.String},
"role": {Name: "Role", DBName: "role", DataType: schema.String},
"name": {Name: "Name", DBName: "name", GORMDataType: schema.String},
"email": {Name: "Email", DBName: "email", GORMDataType: schema.String},
"role": {Name: "Role", DBName: "role", GORMDataType: schema.String},
},
Table: "test_models",
}
Expand Down Expand Up @@ -88,9 +88,9 @@ func TestSearchScopeEmptyField(t *testing.T) {
}
schema := &schema.Schema{
FieldsByDBName: map[string]*schema.Field{
"name": {Name: "Name"},
"email": {Name: "Email"},
"role": {Name: "Role"},
"name": {Name: "Name", GORMDataType: schema.String},
"email": {Name: "Email", GORMDataType: schema.String},
"role": {Name: "Role", GORMDataType: schema.String},
},
Table: "test_models",
}
Expand Down Expand Up @@ -454,9 +454,9 @@ func TestSearchScopeWithUnsupportedDataType(t *testing.T) {

schema := &schema.Schema{
FieldsByDBName: map[string]*schema.Field{
"name": {Name: "Name", DBName: "name", DataType: schema.String},
"email": {Name: "Email", DBName: "email", DataType: "CHARACTER VARYING(255)"},
"role": {Name: "Role", DBName: "role", DataType: schema.String},
"name": {Name: "Name", DBName: "name", GORMDataType: schema.String},
"email": {Name: "Email", DBName: "email", GORMDataType: "custom", DataType: "CHARACTER VARYING(255)"},
"role": {Name: "Role", DBName: "role", GORMDataType: schema.String},
},
Table: "test_models",
}
Expand Down
3 changes: 0 additions & 3 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ func getDataType(field *schema.Field) DataType {
case 64:
return DataTypeFloat64
}
return DataTypeFloat64
case schema.Int:
switch field.Size {
case 8:
Expand All @@ -139,7 +138,6 @@ func getDataType(field *schema.Field) DataType {
case 64:
return DataTypeInt64
}
return DataTypeInt64
case schema.Uint:
switch field.Size {
case 8:
Expand All @@ -151,7 +149,6 @@ func getDataType(field *schema.Field) DataType {
case 64:
return DataTypeUint64
}
return DataTypeUint64
case schema.Time:
return DataTypeTime
}
Expand Down

0 comments on commit 0ac0b7b

Please sign in to comment.