Atlas › Test
TestEncodeEmptyHistories
Exact test identity: go.temporal.io/server/common/codec/TestJSONPBEncoderSuite/TestEncodeEmptyHistories
- Package
go.temporal.io/server/common/codec
- Suite / test hierarchy
TestJSONPBEncoderSuite/TestEncodeEmptyHistories
- Test
TestEncodeEmptyHistories
- Introduced at
- jsonpb.go ×1 Frontier kind: Joint frontier
- Covered ranges
- 4
- Covered lines
- 13
- Covered files
- 1
Covered source
Expand a file to inspect source; the > gutter marks covered lines.
go.temporal.io/server/common/codec/jsonpb.go 13 covered LOC · 4 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 {
98
pb := item(i)
99
bs, err := e.marshaler.Marshal(pb)
107
}
108
}
110
>
return buf.Bytes(), nil
111
}
112