Issue 82 cloud integration disables#111
Conversation
Assert /cloudCost endpoints return HTTP 200 with empty data when billing integration is not configured, and skip when integrations are present. Fixes opencost#82 Signed-off-by: Aadarsh Sankar <aadarshsankar53@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Document test helpers and assertions, and restore the bats runner for the config integration test. Signed-off-by: Aadarsh Sankar <aadarshsankar53@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a new integration test (issue #82) verifying that OpenCost's cloud-cost endpoints behave deterministically when no cloud billing integration is configured. It introduces a config test package and a corresponding bats runner. The test probes /cloudCost/status to confirm no integrations are configured (skipping gracefully on a 404/unconfigured instance), then asserts that /cloudCost, /cloudCost/autocomplete, and /cloudCost/status all return HTTP 200 with empty data and never a 500. This aligns with the acceptance criteria in issue #82 (deterministic, non-500 responses and a status endpoint that reports the integration as not configured).
Changes:
- New Go test
TestCloudCostWhenIntegrationDisabledcovering the three cloud-cost endpoints when integration is disabled, reusingpkg/apihelpers and skipping when the endpoints aren't deployed or integration is present. - New
test.batsrunner wiring the Go test into the bats suite.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/integration/api/config/cloud_integration_disabled_test.go | Adds the Go test asserting empty/deterministic responses from /cloudCost, /cloudCost/autocomplete, and /cloudCost/status with skip guards for undeployed/configured instances. |
| test/integration/api/config/test.bats | Adds a bats test that runs the new Go test from the config directory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| body := getCloudCostEndpoint(t, apiClient, "/cloudCost/autocomplete", api.AutocompleteRequest{ //get the cloud cost autocomplete endpoint | ||
| Window: defaultWindow, | ||
| Field: "service", | ||
| Limit: 1, | ||
| }) //get the cloud cost autocomplete endpoint |
| t.Skipf( | ||
| "cloud billing integration is configured on %s (%d integration(s)); need instance without cloud integration", //if the cloud billing integration is configured, skip the test | ||
| env.GetDefaultURL(), | ||
| len(resp.Data), | ||
| ) //if the cloud billing integration is configured, skip the test |
No description provided.