Skip to content

test(metrics): add unit tests for getMetricsRefreshInterval - #1583

Open
Neha-Nimsatkar wants to merge 1 commit into
flatcar:mainfrom
Neha-Nimsatkar:test/metrics-interval-unit-tests
Open

test(metrics): add unit tests for getMetricsRefreshInterval#1583
Neha-Nimsatkar wants to merge 1 commit into
flatcar:mainfrom
Neha-Nimsatkar:test/metrics-interval-unit-tests

Conversation

@Neha-Nimsatkar

Copy link
Copy Markdown

test(metrics): add unit tests for getMetricsRefreshInterval

This PR adds unit tests for getMetricsRefreshInterval() in the backend/pkg/metrics package. Currently, the metrics package does not have test coverage for environment variable parsing.

The tests cover all parsing scenarios and fallback behaviors:

  • Default fallback when NEBRASKA_METRICS_UPDATE_INTERVAL is unset
  • Valid custom intervals in seconds and minutes (e.g., 30s, 2m)
  • Fallback handling when invalid duration strings, negative durations, or zero durations are passed

How to use

Reviewers can validate this change by running the Go test suite inside the backend package.

Testing done

  • Formatted code using go fmt ./pkg/metrics/...
  • Ran the unit test suite locally:
cd backend
go test -v ./pkg/metrics/...

Signed-off-by: Neha-Nimsatkar <1492neha@gmail.com>
@Neha-Nimsatkar
Neha-Nimsatkar requested a review from a team as a code owner August 14, 2026 06: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.

1 participant