Skip to content

test: add comprehensive integration tests for label mapping validation#135

Merged
d0ugal merged 5 commits intomainfrom
add-integration-tests
Oct 27, 2025
Merged

test: add comprehensive integration tests for label mapping validation#135
d0ugal merged 5 commits intomainfrom
add-integration-tests

Conversation

@d0ugal
Copy link
Copy Markdown
Owner

@d0ugal d0ugal commented Oct 27, 2025

Add integration tests that would have caught the label mapping issues we experienced. These tests verify:

  1. Full Integration Test: Tests the complete collection flow with mock GHCR API responses to ensure metrics are created with correct labels without panicking.

  2. Label Consistency Test: Tests all metrics individually to verify that the labels used in With(prometheus.Labels{}) calls match the metric definitions exactly.

  3. Error Handling Test: Tests error scenarios to ensure they don't cause label mapping panics.

These tests would have caught the 'repo' vs 'name' label mapping bug that caused the panic: label name "repo" missing in label map

The tests use testutil.ToFloat64() to verify metrics are created successfully, which will panic if labels don't match metric definitions.

This provides a safety net for future refactoring and ensures label mapping issues are caught before deployment.

Add integration tests that would have caught the label mapping issues we
experienced. These tests verify:

1. **Full Integration Test**: Tests the complete collection flow with mock
   GHCR API responses to ensure metrics are created with correct labels
   without panicking.

2. **Label Consistency Test**: Tests all metrics individually to verify
   that the labels used in With(prometheus.Labels{}) calls match the
   metric definitions exactly.

3. **Error Handling Test**: Tests error scenarios to ensure they don't
   cause label mapping panics.

These tests would have caught the 'repo' vs 'name' label mapping bug
that caused the panic: label name "repo" missing in label map

The tests use testutil.ToFloat64() to verify metrics are created
successfully, which will panic if labels don't match metric definitions.

This provides a safety net for future refactoring and ensures label
mapping issues are caught before deployment.
@d0ugal d0ugal force-pushed the add-integration-tests branch from 53683b6 to 43d929d Compare October 27, 2025 20:54
@d0ugal d0ugal merged commit b9514fd into main Oct 27, 2025
8 checks passed
@d0ugal d0ugal deleted the add-integration-tests branch October 27, 2025 20:54
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