refactoring
This commit is contained in:
@@ -10,7 +10,7 @@ type User struct {
|
||||
Age int
|
||||
Address *Address
|
||||
Tags []string
|
||||
License License
|
||||
Licence Licence
|
||||
}
|
||||
|
||||
type Address struct {
|
||||
@@ -18,7 +18,7 @@ type Address struct {
|
||||
Country string
|
||||
}
|
||||
|
||||
type License struct {
|
||||
type Licence struct {
|
||||
ID string
|
||||
Categories []string
|
||||
}
|
||||
@@ -98,22 +98,22 @@ func TestFilterAllowedStructFields(t *testing.T) {
|
||||
{
|
||||
name: "Filter slice of structs",
|
||||
input: &User{
|
||||
License: License{
|
||||
Licence: Licence{
|
||||
ID: "123",
|
||||
Categories: []string{"A", "B"},
|
||||
},
|
||||
},
|
||||
existing: &User{
|
||||
License: License{
|
||||
Licence: Licence{
|
||||
ID: "456",
|
||||
Categories: []string{"C"},
|
||||
},
|
||||
},
|
||||
allowedFields: map[string]bool{
|
||||
"License.ID": true,
|
||||
"Licence.ID": true,
|
||||
},
|
||||
expectedResult: &User{
|
||||
License: License{
|
||||
Licence: Licence{
|
||||
ID: "123", // Allowed field
|
||||
Categories: []string{"C"}, // Kept from existing
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user