Atlas › Test
non_nil_maps
Exact test identity: go.temporal.io/server/common/payload/TestMergeMapOfPayload/non_nil_maps
- Package
go.temporal.io/server/common/payload
- Suite / test hierarchy
TestMergeMapOfPayload/non_nil_maps
- Test
non_nil_maps
- Introduced at
- non_nil_maps Frontier kind: Test frontier
- Covered ranges
- 11
- Covered lines
- 27
- Covered files
- 2
Covered source
Expand a file to inspect source; the > gutter marks covered lines.
go.temporal.io/server/common/payload/payload.go 23 covered LOC · 9 ranges
Open complete file
18
)
19
20
>
func EncodeString(str string) *commonpb.Payload {
payload.go
21
>
// Error can be safely ignored here because string always can be converted to JSON
22
>
p, _ := defaultDataConverter.ToPayload(str)
23
>
return p
24
>
}
25
26
func EncodeBytes(bytes []byte) *commonpb.Payload {
30
}
31
32
>
func Encode(value any) (*commonpb.Payload, error) {
payload.go
33
>
return defaultDataConverter.ToPayload(value)
34
>
}
35
36
func Decode(p *commonpb.Payload, valuePtr any) error {
67
dst map[string]*commonpb.Payload,
68
src map[string]*commonpb.Payload,
70
>
if src == nil {
71
return maps.Clone(dst)
72
}
74
>
for k, v := range src {
76
delete(res, k)
79
>
}
80
}
82
}
83
88
// - payload's data is "null" (json encoded value for nil objects)
89
// - payload's data is "[]" (empty slice for backwards compatibility)
90
>
func isNilPayload(p *commonpb.Payload) bool {
payload.go
91
>
return p == nil ||
92
>
bytes.Equal(p.Data, nilPayload.Data) ||
93
>
bytes.Equal(p.Data, nilSlicePayload.Data) ||
94
>
bytes.Equal(p.Data, emptySlicePayload.Data)
95
>
}
96
97
// FilterNilSearchAttributes returns a new SearchAttributes with nil/empty payload values filtered out.
go.temporal.io/server/common/util/util.go 4 covered LOC · 2 ranges
Open complete file
59
60
// CloneMapNonNil is like maps.Clone except it can't return nil, it will return an empty map instead.
61
>
func CloneMapNonNil[M ~map[K]V, K comparable, V any](m M) M {
util.go
62
>
m = maps.Clone(m)
63
>
if m == nil {
64
m = make(M)
65
}
67
}
68