Skip to content

test: add unit tests for mergeAppend, mergeSlice, and isPresent in confmap/internal - #15663

Open
manoj-1407 wants to merge 1 commit into
open-telemetry:mainfrom
manoj-1407:test/merge-append-confmap
Open

test: add unit tests for mergeAppend, mergeSlice, and isPresent in confmap/internal#15663
manoj-1407 wants to merge 1 commit into
open-telemetry:mainfrom
manoj-1407:test/merge-append-confmap

Conversation

@manoj-1407

Copy link
Copy Markdown

Description

confmap/internal/merge.go contains non-trivial logic for merging configuration maps (mergeAppend, mergeSlice, isPresent) but had no test coverage.

Changes

Added confmap/internal/merge_test.go with table-driven tests covering:

  • TestMergeAppend_NonOverlappingKeys — verifies both slices are merged under glob-matched keys
  • TestMergeAppend_DeduplicatesSliceEntries — verifies no duplication when src entry already exists in dest
  • TestMergeAppend_EmptyDest — verifies src populates an empty dest
  • TestMergeAppend_EmptySrc — verifies dest is unchanged when src is empty
  • TestMergeAppend_NonGlobKeyNotMergedAsSlice — verifies non-glob keys follow standard maps.Merge behavior
  • TestMergeAppend_PipelineReceiversMerged — verifies pipeline receiver lists merge correctly via glob pattern
  • TestMergeSlice_AppendsUniqueElements — dest elements first, unique src elements appended
  • TestMergeSlice_EmptySrc / TestMergeSlice_EmptyDest / TestMergeSlice_AllDuplicates — edge cases
  • TestIsPresent — table-driven across present, not present, empty slice, map value cases

Testing

cd confmap && go test ./internal/... 
ok  go.opentelemetry.io/collector/confmap/internal  0.114s

…nfmap/internal

Signed-off-by: manoj-1407 <manojkumar148700@gmail.com>
@manoj-1407
manoj-1407 requested review from a team, evan-bradley and mx-psi as code owners July 27, 2026 04:53
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 27, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: manoj-1407 / name: manoj-1407 (f259a04)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant