Skip to content

test(runtime): convert virtualmodels, streaming, ratelimit, and workflow tests to testify - #980

Open
SantiagoDePolonia wants to merge 4 commits into
test/shared-test-helpersfrom
test/testify-runtime
Open

test(runtime): convert virtualmodels, streaming, ratelimit, and workflow tests to testify#980
SantiagoDePolonia wants to merge 4 commits into
test/shared-test-helpersfrom
test/testify-runtime

Conversation

@SantiagoDePolonia

Copy link
Copy Markdown
Contributor

Converts the hand-rolled assertions in the virtualmodels, streaming, ratelimit, workflows, anthropicapi, mcpgateway, budget, and gateway tests to testify.

  • Adds globalVersionV1(features) in the workflow service tests, replacing twelve identical Version literals.
  • Removes now-unused comparison helpers (equalStrings, formatCandidates).
  • No tests removed; candidates were checked and cover distinct code paths.

Test-only change, about 2,800 net lines removed. Stacked on #976 (helper packages).

@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 0862d834-2fbd-410c-8e49-34096fc173d2

📥 Commits

Reviewing files that changed from the base of the PR and between 958e420 and 2973d0d.

📒 Files selected for processing (66)
  • internal/anthropicapi/batch_test.go
  • internal/anthropicapi/errors_test.go
  • internal/anthropicapi/request_test.go
  • internal/anthropicapi/response_test.go
  • internal/anthropicapi/stream_test.go
  • internal/anthropicapi/token_estimate_test.go
  • internal/budget/service_test.go
  • internal/budget/store_mongodb_test.go
  • internal/budget/store_sql_test.go
  • internal/budget/types_test.go
  • internal/gateway/attempts_test.go
  • internal/gateway/batch_orchestrator_test.go
  • internal/gateway/batch_usage_test.go
  • internal/gateway/edge_cases_test.go
  • internal/gateway/empty_choices_test.go
  • internal/gateway/failover_policy_test.go
  • internal/gateway/failover_test.go
  • internal/gateway/inference_orchestrator_test.go
  • internal/gateway/request_model_resolution_test.go
  • internal/gateway/resilience_failover_test.go
  • internal/gateway/slowdown_test.go
  • internal/mcpgateway/catalog_test.go
  • internal/mcpgateway/originguard_test.go
  • internal/mcpgateway/service_test.go
  • internal/mcpgateway/store_sql_test.go
  • internal/ratelimit/persist_test.go
  • internal/ratelimit/service_test.go
  • internal/ratelimit/store_counters_test.go
  • internal/ratelimit/store_mongodb_test.go
  • internal/ratelimit/store_sql_test.go
  • internal/ratelimit/types_test.go
  • internal/ratelimit/usage_tap_test.go
  • internal/streaming/assemble_test.go
  • internal/streaming/buffered_sse_stream_test.go
  • internal/streaming/leading_whitespace_test.go
  • internal/streaming/observed_sse_stream_test.go
  • internal/streaming/restate_split_test.go
  • internal/streaming/sequence_number_test.go
  • internal/streaming/slowdown_stream_test.go
  • internal/streaming/sse_codec_test.go
  • internal/streaming/sse_event_test.go
  • internal/streaming/stream_buffer_test.go
  • internal/streaming/transformed_sse_stream_test.go
  • internal/streaming/transformed_tool_calls_test.go
  • internal/virtualmodels/access_policy_test.go
  • internal/virtualmodels/adaptive_test.go
  • internal/virtualmodels/balancer_test.go
  • internal/virtualmodels/batch_preparer_test.go
  • internal/virtualmodels/chain_test.go
  • internal/virtualmodels/config_overlay_test.go
  • internal/virtualmodels/failover_test.go
  • internal/virtualmodels/helpers_test.go
  • internal/virtualmodels/legacy_gate_test.go
  • internal/virtualmodels/plugin_strategy_test.go
  • internal/virtualmodels/redirect_rewrite_test.go
  • internal/virtualmodels/rename_test.go
  • internal/virtualmodels/service_test.go
  • internal/virtualmodels/slowdown_test.go
  • internal/virtualmodels/sticky_test.go
  • internal/virtualmodels/store_test.go
  • internal/workflows/compiler_test.go
  • internal/workflows/hold_test.go
  • internal/workflows/service_test.go
  • internal/workflows/store_helpers_test.go
  • internal/workflows/store_sql_test.go
  • internal/workflows/types_test.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Sep 12, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

Safe to merge: the remaining issue affects the clarity of a failing test rather than product behavior.

Reviews (1) · Last reviewed commit: "test(runtime): convert virtualmodels, st..."

Comment thread internal/anthropicapi/request_test.go Outdated
Comment on lines +94 to +95
assert.NotNil(t, chat.MaxTokens)
assert.Equal(t, 256, *chat.MaxTokens)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Avoid nil dereference panic

assert.NotNil records a failure but continues, and the next line unconditionally dereferences chat.MaxTokens. If request conversion returns a nil value, this test reports the intended assertion failure and then panics, obscuring the regression with a less useful stack trace. This is non-blocking, but use require.NotNil here or conditionally perform the dereference after assert.NotNil succeeds.

Artifacts

Evidence from the check

  • Runs a temporary focused Go test with the same Testify assert-then-dereference sequence and removes the temporary source file afterward, demonstrating the nil path.

Command output from the check

  • Runs the existing TestToChatRequestBasic test and shows it passes with the valid max_tokens input, establishing the current normal-path behavior.

Error trace from the failing run

  • Runs the authored nil-path reproduction and shows Testify's non-fatal NotNil failure followed by a nil-pointer SIGSEGV on the next line, confirming the finding.

View artifacts

T-Rex Ran code and verified through T-Rex

@SantiagoDePolonia

Copy link
Copy Markdown
Contributor Author

Addressed the Greptile finding in b2cf52b: internal/anthropicapi/request_test.go used assert.NotNil immediately before dereferencing the pointer (chat.MaxTokens, chat.Temperature, chat.StreamOptions, chat.Reasoning, chat.TopP, parts[1].ImageURL). All six sites now use require.NotNil so a nil value fails the test instead of panicking. No findings were skipped; CodeRabbit was rate-limited and posted no findings. gofmt, go vet, and go test pass for the package.

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