Skip to content

[quality] add 19 tests for audit WebhookDestination.Send, SetStore, and stubs#18230

Merged
kubestellar-hive[bot] merged 3 commits into
mainfrom
quality/test-audit-webhook-setstore
Jun 13, 2026
Merged

[quality] add 19 tests for audit WebhookDestination.Send, SetStore, and stubs#18230
kubestellar-hive[bot] merged 3 commits into
mainfrom
quality/test-audit-webhook-setstore

Conversation

@kubestellar-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds 19 unit tests covering previously-untested code paths in pkg/api/audit:

WebhookDestination.Send (was 0% → 88.2%)

  • Success: verifies JSON payload, headers, event content
  • Empty/nil events: no HTTP call made
  • Non-2xx (500, 403): returns descriptive error
  • Context cancellation: respects caller ctx
  • Payload version: envelope includes version + timestamp

NewWebhookDestination validation

  • Empty URL returns error
  • Nil client creates default with timeout

SetStore / getStore (was 0% → 100%)

  • Nil clears store
  • Round-trip set/get

stubDestination (all providers → 100%)

  • Splunk/Elastic/Syslog stubs return ErrDestinationUnsupported

RegisterDestination edge cases

  • Missing ID rejected
  • Splunk/Elastic/Syslog fallback to stub when config incomplete

Package coverage: 72.1% → 81.7% (+9.6pp)


Filed by quality agent (ACMM L4/L6 — full mode)

… and stubs

Cover previously-untested paths:
- WebhookDestination.Send: success, empty/nil events, non-2xx, context cancellation
- NewWebhookDestination: empty URL validation, nil client default
- SetStore/getStore: nil clears store, round-trip
- stubDestination: all providers return ErrDestinationUnsupported
- RegisterDestination: missing ID, Splunk/Elastic/Syslog stub fallbacks

Package coverage: 72.1% → 81.7% (+9.6pp)

Signed-off-by: Copilot <copilot@example.com>
Copilot AI review requested due to automatic review settings June 13, 2026 00:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mikespreitzer for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Jun 13, 2026
@netlify

netlify Bot commented Jun 13, 2026

Copy link
Copy Markdown

Deploy Preview for kubestellarconsole canceled.

Name Link
🔨 Latest commit f006d21
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6a2caaf1a7e75c0008c6ac92

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey @kubestellar-hive[bot] — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@github-actions github-actions Bot added ai-generated Pull request generated by AI tier/1-lightweight labels Jun 13, 2026
@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 13, 2026
Cover formatter functions with real data scenarios:
- appendFormattedBridgePodIssues: single issue, no-reason/no-issues, truncation
- appendFormattedPodIssues: single issue, no-reason/no-issues
- appendFormattedBridgeWarningEvents: multiple events
- appendFormattedWarningEvents: multiple events, short message preservation
- resolveScopedClusters: nil context, empty values, single cluster
- buildLiveClusterContext: edge cases with nil providers

Key improvements in context.go:
- resolveScopedClusters: 83.3% → 100%
- appendFormattedBridgePodIssues: 23.1% → 100%

Package coverage: 64.7% → 65.9% (+1.2pp)

Signed-off-by: Copilot <copilot@example.com>
@kubestellar-prow kubestellar-prow Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 13, 2026
…gisterWebhookNotifier

Cover previously-undertested branches in SendAlertToChannels:
- Slack channel: success + incomplete config
- PagerDuty channel: incomplete config
- OpsGenie channel: incomplete config
- Email channel: missing port, invalid port, empty recipients, incomplete host
- Webhook channel: invalid URL, empty URL
- Multiple channels with mixed success/failure

RegisterWebhookNotifier:
- Empty URL returns without registering
- Invalid URL logs error, does not register
- Valid URL registers successfully

pkg/notifications coverage: 73.5% → 78.7% (+5.2pp)
SendAlertToChannels: 50.9% → 94.3%
RegisterWebhookNotifier: 62.5% → 100%

Signed-off-by: Copilot <copilot@example.com>
@kubestellar-hive

Copy link
Copy Markdown
Contributor Author

Updated scope — PR now covers 3 packages (49 tests total)

Additional commits pushed:

pkg/agent/kube — 16 tests (64.7% → 65.9%)

  • appendFormattedBridgePodIssues: 23.1% → 100%
  • resolveScopedClusters: 83.3% → 100%

pkg/notifications — 14 tests (73.5% → 78.7%)

  • SendAlertToChannels: 50.9% → 94.3%
  • RegisterWebhookNotifier: 62.5% → 100%

Related: #18231 (interface refactoring for remaining kube context gaps)

@kubestellar-hive kubestellar-hive Bot merged commit 68d7c3d into main Jun 13, 2026
25 of 31 checks passed
@kubestellar-prow kubestellar-prow Bot deleted the quality/test-audit-webhook-setstore branch June 13, 2026 03:52
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

@github-actions

Copy link
Copy Markdown
Contributor

Post-merge build verification passed

Both Go and frontend builds compiled successfully against merge commit 68d7c3d65976161817255000b7914fb64e240f21.

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

Labels

ai-generated Pull request generated by AI dco-signoff: yes Indicates the PR's author has signed the DCO. quality size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. testing tier/1-lightweight

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant