Skip to content

Add unit tests for extractPath, extractHierarchy, and printHierarchy#85

Merged
bosvos merged 1 commit intoldap-tests-asg-5028from
copilot/sub-pr-83-again
Mar 7, 2026
Merged

Add unit tests for extractPath, extractHierarchy, and printHierarchy#85
bosvos merged 1 commit intoldap-tests-asg-5028from
copilot/sub-pr-83-again

Conversation

Copy link

Copilot AI commented Mar 7, 2026

extractPath, extractHierarchy, and printHierarchy (introduced in #83) had no test coverage despite non-trivial logic around DN parsing, tree construction, and conditional formatting.

Tests added (ldap_test.go)

  • Test_extractPath — covers normal DNs, empty string, missing =, trailing = (empty value filtered), = inside value, and whitespace trimming
  • Test_extractHierarchy — covers empty SearchResult, single-entry tree construction, shared-ancestor deduplication across multiple entries, and malformed DN entries
  • Test_printHierarchy — covers nil-safe behaviour, slash-path for non-CN nodes, colon-path for CN nodes with printNodesIfCN=true, and recursive child traversal

Example of path extraction edge cases exercised:

// Value containing '=' uses first '=' as separator
extractPath("CN=John=Doe,DC=com")
// → [{com DC} {John=Doe CN}]

// Trailing '=' is filtered (empty value)
extractPath("DC=com,OU=")
// → [{com DC}]

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Update LDAP debug logging and cmd line tool enhancements Add unit tests for extractPath, extractHierarchy, and printHierarchy Mar 7, 2026
Co-authored-by: bosvos <2437699+bosvos@users.noreply.github.com>

PR #83 Changes
@bosvos bosvos force-pushed the copilot/sub-pr-83-again branch from e43c5d4 to 1b70c1c Compare March 7, 2026 09:37
@bosvos bosvos marked this pull request as ready for review March 7, 2026 09:38
@bosvos bosvos merged commit 1c7f725 into ldap-tests-asg-5028 Mar 7, 2026
1 check passed
@bosvos bosvos deleted the copilot/sub-pr-83-again branch March 7, 2026 09:42
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.

2 participants