-
Notifications
You must be signed in to change notification settings - Fork 4
Build test #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build test #34
Changes from 2 commits
f862356
9f4cfa9
c9ef1d5
03a5534
4998b4c
a62fbee
808fe9e
fe1c2d5
d9fd63b
2a7a1f1
b08a14f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -453,8 +453,8 @@ func unmarshalNode(data *Node, model reflect.Value, included *map[string]*Node) | |
|
||
buf := bytes.NewBuffer(nil) | ||
|
||
json.NewEncoder(buf).Encode(data.Relationships[args[1]]) | ||
json.NewDecoder(buf).Decode(relationship) | ||
json.NewEncoder(buf).Encode(data.Relationships[args[1]]) //nolint:errcheck | ||
json.NewDecoder(buf).Decode(relationship) //nolint:errcheck | ||
|
||
Comment on lines
+456
to
458
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment: We are ignoring the lint error to preserve behaviour. |
||
data := relationship.Data | ||
|
||
|
@@ -483,7 +483,7 @@ func unmarshalNode(data *Node, model reflect.Value, included *map[string]*Node) | |
|
||
buf := bytes.NewBuffer(nil) | ||
relDataStr := data.Relationships[args[1]] | ||
json.NewEncoder(buf).Encode(relDataStr) | ||
json.NewEncoder(buf).Encode(relDataStr) //nolint:errcheck | ||
|
||
isExplicitNull := false | ||
relationshipDecodeErr := json.NewDecoder(buf).Decode(relationship) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -249,7 +249,6 @@ func TestUnmarshalToStructWithPointerAttr_BadType_Struct(t *testing.T) { | |
|
||
func TestUnmarshalToStructWithPointerAttr_BadType_IntSlice(t *testing.T) { | ||
out := new(WithPointer) | ||
type FooStruct struct{ A, B int } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused |
||
in := map[string]interface{}{ | ||
"name": []int{4, 5}, // This is the wrong type. | ||
} | ||
|
@@ -405,7 +404,9 @@ func TestUnmarshalNullableRelationshipsNonNullValue(t *testing.T) { | |
} | ||
|
||
outBuf := bytes.NewBuffer(nil) | ||
json.NewEncoder(outBuf).Encode(payload) | ||
if err := json.NewEncoder(outBuf).Encode(payload); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
out := new(WithNullableAttrs) | ||
|
||
|
@@ -442,7 +443,9 @@ func TestUnmarshalNullableRelationshipsExplicitNullValue(t *testing.T) { | |
} | ||
|
||
outBuf := bytes.NewBuffer(nil) | ||
json.NewEncoder(outBuf).Encode(payload) | ||
if err := json.NewEncoder(outBuf).Encode(payload); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
out := new(WithNullableAttrs) | ||
|
||
|
@@ -467,7 +470,9 @@ func TestUnmarshalNullableRelationshipsNonExistentValue(t *testing.T) { | |
} | ||
|
||
outBuf := bytes.NewBuffer(nil) | ||
json.NewEncoder(outBuf).Encode(payload) | ||
if err := json.NewEncoder(outBuf).Encode(payload); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
out := new(WithNullableAttrs) | ||
|
||
|
@@ -490,7 +495,9 @@ func TestUnmarshalNullableRelationshipsNoRelationships(t *testing.T) { | |
} | ||
|
||
outBuf := bytes.NewBuffer(nil) | ||
json.NewEncoder(outBuf).Encode(payload) | ||
if err := json.NewEncoder(outBuf).Encode(payload); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
out := new(WithNullableAttrs) | ||
|
||
|
@@ -1028,7 +1035,7 @@ func Test_choiceStructMapping(t *testing.T) { | |
t.Errorf("expected \"images\" to be the first field, but got %d", imageField.FieldNum) | ||
} | ||
videoField, ok := result["videos"] | ||
if !ok || videoField.FieldNum != 2 { | ||
if !ok || videoField.FieldNum != 1 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An unused field was removed, thus the FieldNum for videoField decreased |
||
t.Errorf("expected \"videos\" to be the third field, but got %d", videoField.FieldNum) | ||
} | ||
} | ||
|
@@ -1120,7 +1127,10 @@ func TestUnmarshalNestedRelationships(t *testing.T) { | |
} | ||
|
||
func TestUnmarshalRelationshipsSerializedEmbedded(t *testing.T) { | ||
out := sampleSerializedEmbeddedTestModel() | ||
out, err := sampleSerializedEmbeddedTestModel() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if out.CurrentPost == nil { | ||
t.Fatalf("Current post was not materialized") | ||
|
@@ -1169,7 +1179,10 @@ func TestUnmarshalNestedRelationshipsEmbedded(t *testing.T) { | |
} | ||
|
||
func TestUnmarshalRelationshipsSideloaded(t *testing.T) { | ||
payload := samplePayloadWithSideloaded() | ||
payload, err := samplePayloadWithSideloaded() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
out := new(Blog) | ||
|
||
if err := UnmarshalPayload(payload, out); err != nil { | ||
|
@@ -1190,7 +1203,10 @@ func TestUnmarshalRelationshipsSideloaded(t *testing.T) { | |
} | ||
|
||
func TestUnmarshalNestedRelationshipsSideloaded(t *testing.T) { | ||
payload := samplePayloadWithSideloaded() | ||
payload, err := samplePayloadWithSideloaded() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
out := new(Blog) | ||
|
||
if err := UnmarshalPayload(payload, out); err != nil { | ||
|
@@ -1621,7 +1637,7 @@ func samplePayload() io.Reader { | |
} | ||
|
||
out := bytes.NewBuffer(nil) | ||
json.NewEncoder(out).Encode(payload) | ||
json.NewEncoder(out).Encode(payload) //nolint:errcheck | ||
|
||
return out | ||
} | ||
|
@@ -1639,7 +1655,7 @@ func samplePayloadWithID() io.Reader { | |
} | ||
|
||
out := bytes.NewBuffer(nil) | ||
json.NewEncoder(out).Encode(payload) | ||
json.NewEncoder(out).Encode(payload) //nolint:errcheck | ||
|
||
return out | ||
} | ||
|
@@ -1654,7 +1670,7 @@ func samplePayloadWithBadTypes(m map[string]interface{}) io.Reader { | |
} | ||
|
||
out := bytes.NewBuffer(nil) | ||
json.NewEncoder(out).Encode(payload) | ||
json.NewEncoder(out).Encode(payload) //nolint:errcheck | ||
|
||
return out | ||
} | ||
|
@@ -1669,7 +1685,7 @@ func sampleWithPointerPayload(m map[string]interface{}) io.Reader { | |
} | ||
|
||
out := bytes.NewBuffer(nil) | ||
json.NewEncoder(out).Encode(payload) | ||
json.NewEncoder(out).Encode(payload) //nolint:errcheck | ||
|
||
return out | ||
} | ||
|
@@ -1684,7 +1700,7 @@ func samplePayloadWithNullableAttrs(m map[string]interface{}) io.Reader { | |
} | ||
|
||
out := bytes.NewBuffer(nil) | ||
json.NewEncoder(out).Encode(payload) | ||
json.NewEncoder(out).Encode(payload) //nolint:errcheck | ||
|
||
return out | ||
} | ||
|
@@ -1757,23 +1773,29 @@ func testModel() *Blog { | |
} | ||
} | ||
|
||
func samplePayloadWithSideloaded() io.Reader { | ||
func samplePayloadWithSideloaded() (io.Reader, error) { | ||
testModel := testModel() | ||
|
||
out := bytes.NewBuffer(nil) | ||
MarshalPayload(out, testModel) | ||
if err := MarshalPayload(out, testModel); err != nil { | ||
return nil, err | ||
} | ||
|
||
return out | ||
return out, nil | ||
} | ||
|
||
func sampleSerializedEmbeddedTestModel() *Blog { | ||
func sampleSerializedEmbeddedTestModel() (*Blog, error) { | ||
out := bytes.NewBuffer(nil) | ||
MarshalOnePayloadEmbedded(out, testModel()) | ||
if err := MarshalOnePayloadEmbedded(out, testModel()); err != nil { | ||
return nil, err | ||
} | ||
|
||
blog := new(Blog) | ||
UnmarshalPayload(out, blog) | ||
if err := UnmarshalPayload(out, blog); err != nil { | ||
return nil, err | ||
} | ||
|
||
return blog | ||
return blog, nil | ||
} | ||
|
||
func TestUnmarshalNestedStructPtr(t *testing.T) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused field