Atlas › Test
TestEncodeHistories
Exact test identity: go.temporal.io/server/common/codec/TestJSONPBEncoderSuite/TestEncodeHistories
- Package
go.temporal.io/server/common/codec
- Suite / test hierarchy
TestJSONPBEncoderSuite/TestEncodeHistories
- Test
TestEncodeHistories
- Introduced at
- TestEncodeHistories Frontier kind: Test frontier
- Covered ranges
- 7
- Covered lines
- 21
- Covered files
- 1
Covered source
Expand a file to inspect source; the > gutter marks covered lines.
go.temporal.io/server/common/codec/jsonpb.go 21 covered LOC · 7 ranges
Open complete file
23
24
// NewJSONPBEncoder creates a new JSONPBEncoder.
25
>
func NewJSONPBEncoder() JSONPBEncoder {
jsonpb.go
26
>
return JSONPBEncoder{}
27
>
}
28
29
// NewJSONPBIndentEncoder creates a new JSONPBEncoder with indent.
54
55
// Encode History slice to bytes.
56
>
func (e *JSONPBEncoder) EncodeHistories(histories []*historypb.History) ([]byte, error) {
jsonpb.go
57
>
return e.encodeSlice(
58
>
len(histories),
59
>
func(i int) proto.Message { return histories[i] })
60
}
61
92
len int,
93
item func(i int) proto.Message,
95
>
var buf bytes.Buffer
96
>
buf.WriteString("[")
97
>
for i := range len {
99
>
bs, err := e.marshaler.Marshal(pb)
100
>
if err != nil {
101
return nil, err
102
}
104
>
105
>
if i < len-1 {
107
>
}
108
}
110
>
return buf.Bytes(), nil
111
}
112