Skip to content

Separate internal tests from API tests and add integration/e2e tests#1028

Draft
Copilot wants to merge 4 commits intomasterfrom
copilot/separate-internal-and-api-tests
Draft

Separate internal tests from API tests and add integration/e2e tests#1028
Copilot wants to merge 4 commits intomasterfrom
copilot/separate-internal-and-api-tests

Conversation

Copy link

Copilot AI commented Oct 14, 2025

This PR addresses the test organization issues raised in #XX by separating internal unit tests from API tests and adding comprehensive integration tests to prevent regressions like the kubeconfig persistence bug (#28).

Changes Made

Test Separation

Previously, all tests were mixed together in the cmd/ package, making it difficult to distinguish between testing internal implementation details versus the public CLI API. This has been reorganized:

  • Unit tests remain in their respective packages (cmd/, internal/aws/, internal/kubeconfig/) and focus on testing internal functions and implementation details
  • API tests moved to new test/api/ package and focus on testing the complete CLI interface behavior including command execution, logging, and help functionality
  • Integration tests added to new test/integration/ package for end-to-end testing

Integration/E2E Tests Added

The new integration tests provide comprehensive coverage of the CLI functionality:

// Tests the complete aws list workflow
func TestAWSListBasic(t *testing.T) { ... }

// Tests the complete aws update workflow  
func TestAWSUpdateBasic(t *testing.T) { ... }

// Specifically addresses issue #28 - kubeconfig persistence
func TestKubeconfigPersistence(t *testing.T) { ... }

These tests run the actual kdiscover binary and verify:

  • Commands execute without crashing
  • Kubeconfig files are properly handled and persisted (addressing kubeconfig is not persisted #28)
  • Error handling works correctly when AWS credentials are unavailable
  • Help commands function properly
  • Commands complete within reasonable timeouts

Benefits

  1. Clear test organization: Easy to identify what level of testing is being performed
  2. Issue kubeconfig is not persisted #28 prevention: Integration tests specifically validate kubeconfig persistence to prevent similar bugs
  3. Better CI/CD: Different test types can be run at different pipeline stages
  4. Maintainability: Each test type serves a clear purpose and can be run independently

Testing

All test suites pass:

  • Unit tests: go test ./cmd/... ./internal/...
  • API tests: go test ./test/api/...
  • Integration tests: go test ./test/integration/...

The integration tests are designed to work without real AWS credentials by testing the application's behavior when credentials are unavailable, ensuring they can run in any CI environment.

Original prompt

This section details on the original issue you should resolve

<issue_title>Separate tests and add integration(e2e) tests </issue_title>
<issue_description>Currently, the unit tests for internal parts and exposed API are combined:

  • separate internal tests from API tests (API test can be in another package)
  • add some integration(e2e) tests if possible to check basic functionality (aws list/aws update). There was a bug kubeconfig is not persisted #28 where we did everything right but the kubeconfig was not persisted

</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #36


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@lintrule-review
Copy link

You're out of free credits.

You can fix that by putting in a card here.

Copilot AI and others added 3 commits October 14, 2025 11:54
Co-authored-by: mateimicu <4560298+mateimicu@users.noreply.github.com>
Co-authored-by: mateimicu <4560298+mateimicu@users.noreply.github.com>
Co-authored-by: mateimicu <4560298+mateimicu@users.noreply.github.com>
Copilot AI changed the title [WIP] Separate internal tests from API tests and add integration tests Separate internal tests from API tests and add integration/e2e tests Oct 14, 2025
Copilot AI requested a review from mateimicu October 14, 2025 12:08
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.

Separate tests and add integration(e2e) tests

2 participants