forked from Mirrors/jsonapi
Fixed format types
This commit is contained in:
parent
ccac636b4b
commit
87c6b8e5b5
|
@ -254,10 +254,10 @@ func unmarshalNode(data *Node, model reflect.Value, included *map[string]*Node)
|
||||||
}
|
}
|
||||||
|
|
||||||
// As a final catch-all, ensure types line up to avoid a runtime panic.
|
// As a final catch-all, ensure types line up to avoid a runtime panic.
|
||||||
if fieldValue.Kind() != v.Kind() {
|
if fieldValue.Kind() != value.Kind() {
|
||||||
return ErrInvalidType
|
return ErrInvalidType
|
||||||
}
|
}
|
||||||
assignValue(fieldValue, reflect.ValueOf(val))
|
assignValue(fieldValue, value)
|
||||||
} else if annotation == annotationRelation {
|
} else if annotation == annotationRelation {
|
||||||
isSlice := fieldValue.Type().Kind() == reflect.Slice
|
isSlice := fieldValue.Type().Kind() == reflect.Slice
|
||||||
|
|
||||||
|
|
|
@ -799,17 +799,17 @@ func TestUnmarshalCustomTypeAttributes(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if expected, actual := customInt, customAttributeTypes.Int; expected != actual {
|
if expected, actual := customInt, customAttributeTypes.Int; expected != actual {
|
||||||
t.Fatalf("Was expecting custom int to be `%s`, got `%s`", expected, actual)
|
t.Fatalf("Was expecting custom int to be `%d`, got `%d`", expected, actual)
|
||||||
}
|
}
|
||||||
if expected, actual := customInt, *customAttributeTypes.IntPtr; expected != actual {
|
if expected, actual := customInt, *customAttributeTypes.IntPtr; expected != actual {
|
||||||
t.Fatalf("Was expecting custom int pointer to be `%s`, got `%s`", expected, actual)
|
t.Fatalf("Was expecting custom int pointer to be `%d`, got `%d`", expected, actual)
|
||||||
}
|
}
|
||||||
if customAttributeTypes.IntPtrNull != nil {
|
if customAttributeTypes.IntPtrNull != nil {
|
||||||
t.Fatalf("Was expecting custom int pointer to be <nil>, got `%s`", customAttributeTypes.IntPtrNull)
|
t.Fatalf("Was expecting custom int pointer to be <nil>, got `%d`", customAttributeTypes.IntPtrNull)
|
||||||
}
|
}
|
||||||
|
|
||||||
if expected, actual := customFloat, customAttributeTypes.Float; expected != actual {
|
if expected, actual := customFloat, customAttributeTypes.Float; expected != actual {
|
||||||
t.Fatalf("Was expecting custom float to be `%s`, got `%s`", expected, actual)
|
t.Fatalf("Was expecting custom float to be `%f`, got `%f`", expected, actual)
|
||||||
}
|
}
|
||||||
if expected, actual := customString, customAttributeTypes.String; expected != actual {
|
if expected, actual := customString, customAttributeTypes.String; expected != actual {
|
||||||
t.Fatalf("Was expecting custom string to be `%s`, got `%s`", expected, actual)
|
t.Fatalf("Was expecting custom string to be `%s`, got `%s`", expected, actual)
|
||||||
|
|
Loading…
Reference in New Issue