Atlas › Test

TestGetOrSetMap_CreatesNew

Exact test identity: go.temporal.io/server/common/util/TestGetOrSetMap_CreatesNew

Package
go.temporal.io/server/common/util
Suite / test hierarchy
TestGetOrSetMap_CreatesNew
Test
TestGetOrSetMap_CreatesNew
Introduced at
util.go ×1 Frontier kind: Joint frontier
Covered ranges
2
Covered lines
5
Covered files
1

Co-introduced tests

1 other test enter at the same concept.

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/common/util/util.go 5 covered LOC · 2 ranges

Open complete file

92 // GetOrSetMap looks up k in m, a two-level map, and returns the result. If it's not present,
93 // it uses `make` to allocate new second-level map and sets that in the first map, then returns it.
94 > func GetOrSetMap[M ~map[K]M2, M2 ~map[K2]V, K, K2 comparable, V any](m M, k K) M2 { util.go
95 > if m2, ok := m[k]; ok {
96 return m2
97 }
98 > m2 := make(M2) util.go
99 > m[k] = m2
100 > return m2
101 }
102