fix tests

This commit is contained in:
Morgan Bazalgette 2020-10-07 19:22:45 +02:00 committed by Mike Farah
parent a125495eec
commit bb9cb0c60e
3 changed files with 27 additions and 23 deletions

View File

@ -111,7 +111,7 @@ true: true
if result.Error != nil { if result.Error != nil {
t.Error(result.Error) t.Error(result.Error)
} }
expectedOutput := `{"5":{"null":{"0.1":"deeply","false":"things"}},"true":true} expectedOutput := `{"true":true,"5":{"null":{"0.1":"deeply","false":"things"}}}
` `
test.AssertResult(t, expectedOutput, result.Output) test.AssertResult(t, expectedOutput, result.Output)
} }
@ -583,7 +583,7 @@ func TestReadMergeAnchorsExplodeJsonCmd(t *testing.T) {
if result.Error != nil { if result.Error != nil {
t.Error(result.Error) t.Error(result.Error)
} }
expectedOutput := `{"bar":{"b":2,"c":"oldbar","thing":"coconut"},"foo":{"a":"original","thing":"coolasdf","thirsty":"yep"},"foobar":{"a":"original","c":3,"thing":"ice","thirsty":"yep","thirty":"well beyond"},"foobarList":{"a":"original","b":2,"c":"newbar","thing":"coconut","thirsty":"yep"}} expectedOutput := `{"foo":{"a":"original","thing":"coolasdf","thirsty":"yep"},"bar":{"b":2,"thing":"coconut","c":"oldbar"},"foobarList":{"c":"newbar","b":2,"thing":"coconut","a":"original","thirsty":"yep"},"foobar":{"thirty":"well beyond","thing":"ice","c":3,"a":"original","thirsty":"yep"}}
` `
test.AssertResult(t, expectedOutput, result.Output) test.AssertResult(t, expectedOutput, result.Output)
} }
@ -962,6 +962,7 @@ b:
value: 3 value: 3
- name: sam - name: sam
value: 4 value: 4
ab: must appear last
` `
test.AssertResult(t, expectedOutput, result.Output) test.AssertResult(t, expectedOutput, result.Output)
} }
@ -1001,6 +1002,7 @@ b:
value: 3 value: 3
- name: sam - name: sam
value: 4 value: 4
ab: must appear last
` `
test.AssertResult(t, expectedOutput, result.Output) test.AssertResult(t, expectedOutput, result.Output)
} }

View File

@ -1 +1 @@
{"a":"Easy! as one two three","b":{"c":2,"d":[3,4],"e":[{"name":"fred","value":3},{"name":"sam","value":4}]}} {"a":"Easy! as one two three","b":{"c":2,"d":[3,4],"e":[{"name":"fred","value":3},{"name":"sam","value":4}]},"ab":"must appear last"}

View File

@ -166,7 +166,9 @@ func (o orderedMap) MarshalJSON() ([]byte, error) {
return nil, err return nil, err
} }
buf.WriteByte(':') buf.WriteByte(':')
enc.Encode(el.V) if err := enc.Encode(el.V); err != nil {
return nil, err
}
if idx != len(o.kv)-1 { if idx != len(o.kv)-1 {
buf.WriteByte(',') buf.WriteByte(',')
} }