Skip to content

test(Common): add tests for Types/Metrics/RecordingRuleDefinitionUtil#2576

Open
suvvvv wants to merge 1 commit into
OneUptime:masterfrom
suvvvv:test/recording-rule-definition
Open

test(Common): add tests for Types/Metrics/RecordingRuleDefinitionUtil#2576
suvvvv wants to merge 1 commit into
OneUptime:masterfrom
suvvvv:test/recording-rule-definition

Conversation

@suvvvv

@suvvvv suvvvv commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

What

Adds unit tests for the RecordingRuleDefinitionUtil class in Common/Types/Metrics/RecordingRuleDefinition.ts, which previously had no test coverage.

Covered:

  • getAggregationOptions — every option has a label and a valid AggregationType value.
  • getNextAliasA when empty, the first unused letter otherwise, and skips gaps (e.g. A, CB).
  • getEmptyDefinition — a single A source with expression A, and that it validates once a metric name is set.
  • getValidationError — the full set of branches: missing definition, no sources, too many sources, invalid alias, duplicate alias, missing metric name, half-specified attribute filter, missing/over-length expression, undefined alias reference, alias-less expression, and characters outside the DSL grammar. Plus the happy path returning null.

Why

Improves test coverage for the Common/Types utilities (part of the broader test-coverage effort).

Testing

node node_modules/.bin/jest --runInBand ./Tests/Types/Metrics/RecordingRuleDefinition.test.ts

All 19 tests pass. The file is Prettier-clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@simlarsen

Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

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