Skip to content

Commit

Permalink
Fix for issue linkedin#110
Browse files Browse the repository at this point in the history
  • Loading branch information
pkedy committed May 23, 2018
1 parent fa8f6a3 commit 3543862
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions record.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ func makeRecordCodec(st map[string]*Codec, enclosingNamespace string, schemaMap
return nil, fmt.Errorf("Record %q ought to have fields key", c.typeName)
}
fieldSchemas, ok := fields.([]interface{})
if !ok || len(fieldSchemas) == 0 {
return nil, fmt.Errorf("Record %q fields ought to be non-empty array: %v", c.typeName, fields)
if !ok || fieldSchemas == nil {
return nil, fmt.Errorf("Record %q fields ought to be non-nil array: %v", c.typeName, fields)
}

codecFromFieldName := make(map[string]*Codec)
Expand Down
8 changes: 4 additions & 4 deletions record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ func TestRecordName(t *testing.T) {

func TestRecordFields(t *testing.T) {
testSchemaInvalid(t, `{"type":"record","name":"r1"}`, `Record "r1" ought to have fields key`)
testSchemaInvalid(t, `{"type":"record","name":"r1","fields":3}`, `Record "r1" fields ought to be non-empty array`)
testSchemaInvalid(t, `{"type":"record","name":"r1","fields":[]}`, `Record "r1" fields ought to be non-empty array`)
testSchemaInvalid(t, `{"type":"record","name":"r1","fields":3}`, `Record "r1" fields ought to be non-nil array`)
testSchemaInvalid(t, `{"type":"record","name":"r1","fields":null}`, `Record "r1" fields ought to be non-nil array`)
}

func TestRecordFieldInvalid(t *testing.T) {
Expand Down Expand Up @@ -534,7 +534,7 @@ func ExampleBinaryFromNative() {
"LongList": map[string]interface{}{
"next": map[string]interface{}{
"LongList": map[string]interface{}{
// NOTE: May omit fields when using default value
// NOTE: May omit fields when using default value
},
},
},
Expand Down Expand Up @@ -620,7 +620,7 @@ func ExampleTextualFromNative() {
"LongList": map[string]interface{}{
"next": map[string]interface{}{
"LongList": map[string]interface{}{
// NOTE: May omit fields when using default value
// NOTE: May omit fields when using default value
},
},
},
Expand Down

0 comments on commit 3543862

Please sign in to comment.