Skip to content

Added empty window tests for Assets and Allocations api#102

Open
HardingEthan15 wants to merge 2 commits into
opencost:mainfrom
e-300:add-empty-window-tests
Open

Added empty window tests for Assets and Allocations api#102
HardingEthan15 wants to merge 2 commits into
opencost:mainfrom
e-300:add-empty-window-tests

Conversation

@HardingEthan15

Copy link
Copy Markdown

DESCRIPTION

Adds two empty windows tests for OpenCost api. These tests validate that the apis can handle windows where data does not exist.

CHANGES

Adds empty_window_test.go under test/integration/api/allocation
Adds to the test.bats file to run the empty window test
Adds empty_window_test.go under test/integration/api/asset
Adds to the test.bats file to run the empty window test

MOTIVATION

OpenCost should be able handle api calls for data that does not exist, and should return 2** responses with empty datasets instead of 5** responses or panics.

TESTING

These tests can be ran from the test.bats files in the allocation and asset folders.

Signed-off-by: [Ethan.Harding@ibm.com]

Signed-off-by: HardingEthan15 <Ethan.Harding@ibm.com>
@HardingEthan15 HardingEthan15 requested a review from a team as a code owner June 15, 2026 21:51
Copilot AI review requested due to automatic review settings June 15, 2026 21:51

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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR adds integration tests that verify the assets and allocation APIs handle "empty window" queries gracefully—returning well-formed HTTP 200 responses with empty data rather than panicking or returning 5xx errors.

Changes:

  • Added empty window integration tests for the assets API covering far-past, future, and beyond-retention windows across multiple asset types.
  • Added empty window integration tests for the allocation API covering similar time windows across different aggregation levels.
  • Updated bats test files to include the new test targets.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
test/integration/api/asset/test.bats Registers the new asset empty window test
test/integration/api/asset/empty_window_test.go New Go test validating assets API responses for data-less windows
test/integration/api/allocation/test.bats Registers the new allocation empty window test
test/integration/api/allocation/empty_window_test.go New Go test validating allocation API responses for data-less windows

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

{
name: "FarPastWindow",
window: "1970-01-01T00:00:00Z,1970-01-02T00:00:00Z",
aggregate: "namespace",
Comment thread test/integration/api/allocation/empty_window_test.go
Signed-off-by: HardingEthan15 <Ethan.Harding@ibm.com>
@HardingEthan15 HardingEthan15 requested a review from Copilot June 16, 2026 16:59

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

{
name: "FarPastWindow",
window: "1970-01-01T00:00:00Z,1970-01-02T00:00:00Z",
aggregate: "namespace",
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.

2 participants