MCPcopy Create free account
hub / github.com/github/gh-aw / TestMergeOTLPStringMaps

Function TestMergeOTLPStringMaps

pkg/workflow/observability_otlp_test.go:2111–2137  ·  view source on GitHub ↗

TestMergeOTLPStringMaps verifies that mergeOTLPStringMaps correctly merges two attribute maps with base taking precedence.

(t *testing.T)

Source from the content-addressed store, hash-verified

2109// TestMergeOTLPStringMaps verifies that mergeOTLPStringMaps correctly
2110// merges two attribute maps with base taking precedence.
2111func TestMergeOTLPStringMaps(t *testing.T) {
2112 t.Run("nil inputs return nil", func(t *testing.T) {
2113 assert.Nil(t, mergeOTLPStringMaps(nil, nil))
2114 })
2115
2116 t.Run("base only is returned as-is", func(t *testing.T) {
2117 base := map[string]string{"a": "1"}
2118 result := mergeOTLPStringMaps(base, nil)
2119 assert.Equal(t, map[string]string{"a": "1"}, result)
2120 })
2121
2122 t.Run("override only is returned as-is", func(t *testing.T) {
2123 override := map[string]string{"b": "2"}
2124 result := mergeOTLPStringMaps(nil, override)
2125 assert.Equal(t, map[string]string{"b": "2"}, result)
2126 })
2127
2128 t.Run("base keys override the same key from override", func(t *testing.T) {
2129 base := map[string]string{"a": "base-value", "b": "base-b"}
2130 override := map[string]string{"a": "override-value", "c": "override-c"}
2131 result := mergeOTLPStringMaps(base, override)
2132 require.NotNil(t, result)
2133 assert.Equal(t, "base-value", result["a"], "base should win for key 'a'")
2134 assert.Equal(t, "base-b", result["b"], "base-only key 'b' should be present")
2135 assert.Equal(t, "override-c", result["c"], "override-only key 'c' should be present")
2136 })
2137}
2138
2139// TestEncodeOTLPCustomAttributes verifies serialisation to JSON.
2140func TestEncodeOTLPCustomAttributes(t *testing.T) {

Callers

nothing calls this directly

Calls 2

mergeOTLPStringMapsFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected