Skip to content

fix: make action acceptance test idempotent#70

Merged
KT-Doan merged 3 commits intomainfrom
fix/action-test-idempotent
Feb 25, 2026
Merged

fix: make action acceptance test idempotent#70
KT-Doan merged 3 commits intomainfrom
fix/action-test-idempotent

Conversation

@KT-Doan
Copy link
Collaborator

@KT-Doan KT-Doan commented Feb 24, 2026

Description

Add pre-test cleanup for dangling webhooks in TestAccActionResource_basic. When sharing a single smoke-test project, a previous failed test run can leave a webhook behind, causing subsequent runs to fail with "Hook Already Exists".

The cleanup function:

  1. Checks if the test webhook already exists on the project
  2. If found, removes it via a PatchProject call
  3. Logs a message when cleanup occurs for visibility

This makes the test resilient to previous failures without changing any resource logic.

Related Issues

Fixes flaky TestAccActionResource_basic in CI (observed on PRs #68 and #69).

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • I have read the CONTRIBUTING guide
  • My code follows the existing code style
  • I have added tests that prove my fix/feature works
  • I have updated documentation as needed
  • All new and existing tests pass (make test)
  • I have run the linter (make format)

Testing

  • Acceptance tests — verified both scenarios:
    • Clean state: test passes normally
    • Dangling webhook: cleanup runs, removes hook, test passes

Screenshots/Output

With dangling webhook (cleanup in action):

=== RUN   TestAccActionResource_basic
    acctest.go:127: Using pre-created test project: 3fa274fe-... (slug: sad-moser-..., environment: )
    resource_test.go:97: Cleaning up dangling webhook at .../password/hooks: https://webhook.example.com/user-registered
--- PASS: TestAccActionResource_basic (4.71s)
PASS

Without dangling webhook (normal run):

=== RUN   TestAccActionResource_basic
    acctest.go:127: Using pre-created test project: 3fa274fe-... (slug: sad-moser-..., environment: )
--- PASS: TestAccActionResource_basic (3.40s)
PASS

Add pre-test cleanup for dangling webhooks in TestAccActionResource_basic.
When sharing a single smoke-test project, a previous failed test run can
leave a webhook behind, causing subsequent runs to fail with "Hook Already
Exists". The cleanup detects and removes the dangling webhook before the
test creates a new one.
Copilot AI review requested due to automatic review settings February 24, 2026 14:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds pre-test cleanup to TestAccActionResource_basic to make the test idempotent when reusing a shared smoke-test project. The cleanup function detects and removes dangling webhooks left behind by previous failed test runs, preventing "Hook Already Exists" errors that cause test failures.

Changes:

  • Added cleanupDanglingWebhook helper function to detect and remove test webhooks before test execution
  • Modified TestAccActionResource_basic PreCheck to call the cleanup function
  • Added explicit webhook URL and hook path variables for the test

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Derive config path segments from hookPath parameter instead of hardcoding
- Add nil check after map lookups to prevent panic on missing segments
- Remove only the matching webhook, preserving other hooks at the same path
@KT-Doan KT-Doan merged commit 7921f22 into main Feb 25, 2026
11 checks passed
@KT-Doan KT-Doan deleted the fix/action-test-idempotent branch February 25, 2026 09:51
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.

3 participants