Skip to content

Added Unit Tests for ExtractTargets (Now TestFindTargetsInNetwork)#2499

Open
evanwang9x wants to merge 1 commit into
skupperproject:mainfrom
evanwang9x:Evan/addExtractTargetTests
Open

Added Unit Tests for ExtractTargets (Now TestFindTargetsInNetwork)#2499
evanwang9x wants to merge 1 commit into
skupperproject:mainfrom
evanwang9x:Evan/addExtractTargetTests

Conversation

@evanwang9x

@evanwang9x evanwang9x commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Closes #2478

Changed the name of the function ExtractTargets to FindTargetsInNetwork since there was another function in per_target_listener.go called ExtractTargets and was a bit confusing.

Summary by CodeRabbit

  • Tests

    • Expanded unit test coverage for target discovery in the networking logic, including edge cases like empty networks, prefix variations, connector presence/absence, duplicates across sites, and multi-site/multi-target scenarios.
  • Refactor

    • Updated the internal target-discovery flow to use a dedicated “find targets” routine while preserving the existing behavior and results.

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a380f02f-3468-4891-97a7-212e2f8cd16b

📥 Commits

Reviewing files that changed from the base of the PR and between 2de79a8 and 7d64452.

📒 Files selected for processing (2)
  • internal/kube/site/per_target_listener.go
  • internal/kube/site/per_target_listener_test.go

📝 Walkthrough

Walkthrough

Renames the internal helper extractTargets to findTargetsInNetwork in per_target_listener.go (call site and declaration), with no behavioral change. Adds a new table-driven test file covering routing-key prefix matching, connector filtering, edge cases, duplicates, and empty inputs.

Changes

Helper rename and unit tests

Layer / File(s) Summary
Rename extractTargetsfindTargetsInNetwork
internal/kube/site/per_target_listener.go
Call site in PerTargetListener.extractTargets and the function declaration are updated to findTargetsInNetwork; iteration and selection logic is unchanged.
Table-driven tests for findTargetsInNetwork
internal/kube/site/per_target_listener_test.go
TestFindTargetsInNetwork enumerates cases: empty network, prefix match/no-match, services with and without connectors, multiple sites and targets, empty prefix, prefix without dot separator, duplicate targets across sites, and sites with no services. The runner calls findTargetsInNetwork and asserts results with assert.DeepEqual.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding unit tests for ExtractTargets (renamed to FindTargetsInNetwork), which is the primary focus of this PR.
Linked Issues check ✅ Passed The PR fully implements the requirements from issue #2478: adds table-driven unit tests in per_target_listener_test.go covering all specified scenarios (matching/non-matching prefixes, connectors present/absent).
Out of Scope Changes check ✅ Passed All changes are in scope. The refactoring of extractTargets to findTargetsInNetwork is directly related to issue #2478, and the 2-line change in per_target_listener.go updates only the function call to reflect the rename.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@skupperproject skupperproject deleted a comment from coderabbitai Bot Jun 17, 2026
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.

Add unit tests for extractTargets in per-target listener logic

1 participant