Skip to content

Commit a801136

Browse files
committedFeb 25, 2025
add UT
1 parent ee6d526 commit a801136

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
 

‎record.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"sync/atomic"
1515
)
1616

17-
var stringNull int32
17+
var stringNull int32 = 1
1818

1919
func makeRecordCodec(st map[string]*Codec, enclosingNamespace string, schemaMap map[string]interface{}, cb *codecBuilder) (*Codec, error) {
2020
// NOTE: To support recursive data types, create the codec and register it

‎record_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,12 @@ func TestRecordFieldDefaultValue(t *testing.T) {
396396
func TestRecordFieldUnionDefaultValue(t *testing.T) {
397397
testSchemaValid(t, `{"type":"record","name":"r1","fields":[{"name":"f1","type":["int","null"],"default":13}]}`)
398398
testSchemaValid(t, `{"type":"record","name":"r1","fields":[{"name":"f1","type":["null","int"],"default":null}]}`)
399+
testSchemaValid(t, `{"type":"record","name":"r1","fields":[{"name":"f1","type":["null","int"],"default":"null"}]}`)
400+
DisableStringNull()
401+
testSchemaInvalid(t, `{"type":"record","name":"r1","fields":[{"name":"f1","type":["null","int"],"default":"null"}]}`,
402+
"default value ought to encode using field schema")
403+
EnableStringNull()
404+
testSchemaValid(t, `{"type":"record","name":"r1","fields":[{"name":"f1","type":["null","int"],"default":"null"}]}`)
399405
}
400406

401407
func TestRecordFieldUnionInvalidDefaultValue(t *testing.T) {

0 commit comments

Comments
 (0)