Skip to content

Add integration tests for all CommandFlags overloads - #393

Merged
currantw merged 19 commits into
valkey-io:mainfrom
currantw:currantw/254_add_missing_command_flags_tests
May 12, 2026
Merged

Add integration tests for all CommandFlags overloads#393
currantw merged 19 commits into
valkey-io:mainfrom
currantw:currantw/254_add_missing_command_flags_tests

Conversation

@currantw

@currantw currantw commented May 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add integration tests for all missing CommandFlags overloads across the StackExchange.Redis compatibility surface (previously 194/253 were covered).

Issue Link

Closes #254

Features, Behaviour Changes, and Implementation

  • All CommandFlags overloads now have integration tests verifying they throw NotImplementedException when a flag other than CommandFlags.None is passed.
  • ValkeyServer.ScriptExistsAsync and ScriptLoadAsync now check CommandFlags before validating other arguments, consistent with the rest of the codebase.
  • Unrelated: Taskfile now supports filter variable for filtering tests by class or method name (e.g. task test:integration filter=CommandFlagsTests).

Limitations

⚪ None

Testing

  • Tests verified with task test:integration filter=CommandFlagsTests.

Related Issues

⚪ None

Checklist

  • This Pull Request is related to one issue.
  • Commit message has a detailed description of what changed and why.
  • Tests are added or updated and all checks pass.
  • CHANGELOG.md, README.md, DEVELOPER.md, and other documentation files are updated.
  • Destination branch is correct - main or release
  • Create merge commit if merging release branch into main, squash otherwise.

Summary by CodeRabbit

  • Bug Fixes

    • Validation order in script operations improved to reject invalid command flags earlier.
  • Documentation

    • Developer and agent guides updated with explicit task-based test commands and examples using filter= to run specific classes/methods.
  • Tests

    • Expanded integration coverage for command-flag handling across strings, streams, server/transaction/subscriber APIs and scripts.
    • FT.INFO tests now create indexes with explicit prefixes to scope test data.
  • Chores

    • Task runner now supports target selection and optional test filtering via parameters.

Review Change Stack

currantw added 9 commits May 11, 2026 17:56
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Comment thread DEVELOPER.md
Comment thread Taskfile.yml
@currantw currantw added tests Unit tests, integration tests, or test utilities release-1.2 dev Internal changes like cleanup, refactoring, or developer tools. labels May 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds missing integration coverage for StackExchange.Redis-compatible CommandFlags overloads to ensure unsupported flags consistently throw NotImplementedException, and aligns a couple of server scripting methods with that behavior. Also extends the Taskfile to support a simple test filter variable.

Changes:

  • Added many new CommandFlags integration tests across DB/server/subscriber surfaces.
  • Updated ValkeyServer.ScriptExistsAsync / ScriptLoadAsync to check CommandFlags before other argument validation.
  • Added filter support to task test:unit / task test:integration (and updated docs).

Reviewed changes

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

Show a summary per file
File Description
tests/Valkey.Glide.IntegrationTests/StackExchange/CommandFlagsTests.cs Adds extensive integration tests asserting unsupported CommandFlags throw NotImplementedException.
sources/Valkey.Glide/Abstract/ValkeyServer.cs Reorders validation so unsupported flags fail fast for script APIs.
Taskfile.yml Adds filter variable support for dotnet test filtering; refactors build target variable.
DEVELOPER.md Documents how to use the new Taskfile filter variable for tests.
AGENTS.md Updates agent-facing test filtering instructions (currently inconsistent with Taskfile).

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

Comment thread Taskfile.yml Outdated
Comment thread AGENTS.md Outdated
currantw added 2 commits May 12, 2026 08:43
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
@currantw
currantw requested review from alexr-bq and xShinnRyuu May 12, 2026 15:47
@coderabbitai

coderabbitai Bot commented May 12, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds broad CommandFlags integration tests, reorders flag validation in ValkeyServer script methods to run before argument checks, and updates Taskfile and docs to enable running filtered tests via task commands.

Changes

Test Infrastructure & Documentation Updates

Layer / File(s) Summary
Taskfile parameterized test filtering and build targets
Taskfile.yml
Introduce TARGET, BUILD_TARGET, FILTER, and TEST_FILTER; update test:unit/test:integration to append TEST_FILTER and make build use BUILD_TARGET.
Test execution documentation
AGENTS.md, DEVELOPER.md
Replace prior dotnet test --filter examples with task test:unit / task test:integration usage and add filter= examples for selecting test classes or methods.

CommandFlags Validation & Integration Test Coverage

Layer / File(s) Summary
ValkeyServer script method validation order
sources/Valkey.Glide/Abstract/ValkeyServer.cs
ScriptExistsAsync and ScriptLoadAsync overloads now call GuardClauses.ThrowIfCommandFlags(flags) before null/empty argument checks.
CommandFlagsTests integration test suite
tests/Valkey.Glide.IntegrationTests/StackExchange/CommandFlagsTests.cs
Expanded tests adding StringSet/StringSetAndGet with expiry checks, a comprehensive block of Stream command flag tests, IServer command tests, IDatabaseAsync tests, transaction tests, and subscriber tests that assert NotImplementedException when unsupported CommandFlags are passed.
FT.INFO tests updated to use prefixes
tests/Valkey.Glide.IntegrationTests/ServerModules/FtInfoTests.cs
Multiple FT.INFO tests now create indexes with explicit per-test prefixes via Ft.CreateOptions { Prefixes = [prefix] }.

Sequence Diagram

sequenceDiagram
  participant CommandFlagsTests
  participant API_Method
  participant GuardClauses
  CommandFlagsTests->>API_Method: invoke with UnsupportedFlag
  API_Method->>GuardClauses: ThrowIfCommandFlags(flags)
  GuardClauses-->>API_Method: throw NotImplementedException
  API_Method-->>CommandFlagsTests: NotImplementedException raised
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped through flags and tests tonight,
Filters set, prefixes placed just right,
Guards now check before arguments cry,
Tests expanded, assertions fly,
A rabbit’s cheer for coverage bright.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check ❓ Inconclusive The PR implements the core objective of issue #254 by adding 45+ new CommandFlags test methods covering Stream commands, String/Hash expiry operations, and server/database/subscriber operations. However, HyperLogLog command tests (HyperLogLogAddAsync, HyperLogLogLengthAsync, HyperLogLogMergeAsync) and ChannelMessageQueue.UnsubscribeAsync mentioned in issue #254 requirements are only partially covered. Verify that all HyperLogLog overloads and ChannelMessageQueue.UnsubscribeAsync are included in the test coverage, or document why specific overloads from issue #254 are excluded.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and specifically describes the main change: adding integration tests for all CommandFlags overloads.
Description check ✅ Passed The PR description covers Summary, Issue Link, Features/Implementation, Testing, and Checklist, though some template sections like Limitations are present but marked as 'None'.
Out of Scope Changes check ✅ Passed The PR includes on-scope changes (CommandFlags tests, ValkeyServer.ScriptExistsAsync/ScriptLoadAsync flag validation reordering) and a supporting change (Taskfile filter variable for test filtering). The Taskfile and documentation updates (AGENTS.md, DEVELOPER.md) directly enable the test execution workflow.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
tests/Valkey.Glide.IntegrationTests/StackExchange/CommandFlagsTests.cs (2)

441-447: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Duplicate test assertions - likely missing DateTime overload coverage.

Lines 444 and 446 call the same method with identical parameters. Based on the pattern in the SingleField tests (lines 433-437), this should test both the TimeSpan-based and DateTime-based overloads of HashFieldSetAndSetExpiryAsync for multi-field operations.

🔄 Suggested fix to test both overloads
     [Theory(DisableDiscoveryEnumeration = true)]
     [MemberData(nameof(TestConfiguration.TestDatabases), MemberType = typeof(TestConfiguration))]
     public async Task HashFieldSetAndSetExpiryAsync_MultiField_ThrowsOnCommandFlags(IDatabaseAsync db)
     {
         _ = await Assert.ThrowsAsync<NotImplementedException>(
-            () => db.HashFieldSetAndSetExpiryAsync("key", [], flags: UnsupportedFlag));
+            () => db.HashFieldSetAndSetExpiryAsync("key", new[] { new HashFieldValue("field", "value", TimeSpan.Zero) }, flags: UnsupportedFlag));
         _ = await Assert.ThrowsAsync<NotImplementedException>(
-            () => db.HashFieldSetAndSetExpiryAsync("key", [], flags: UnsupportedFlag));
+            () => db.HashFieldSetAndSetExpiryAsync("key", new[] { new HashFieldValue("field", "value", DateTime.MinValue) }, flags: UnsupportedFlag));
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/Valkey.Glide.IntegrationTests/StackExchange/CommandFlagsTests.cs`
around lines 441 - 447, The two assertions in
HashFieldSetAndSetExpiryAsync_MultiField_ThrowsOnCommandFlags currently call the
same TimeSpan overload twice; update the second Assert.ThrowsAsync to call the
DateTime overload of HashFieldSetAndSetExpiryAsync so the test covers both
overloads (keep using the same key, empty field list and UnsupportedFlag),
referencing the IDatabaseAsync.HashFieldSetAndSetExpiryAsync(DateTime) signature
to ensure the DateTime-based overload is invoked.

421-427: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Duplicate test assertions - likely missing DateTime overload coverage.

Lines 424 and 426 call the same method with identical parameters. Based on the pattern in the SingleField tests (lines 411-417), this should test both the TimeSpan-based and DateTime-based overloads of HashFieldGetAndSetExpiryAsync for multi-field operations.

🔄 Suggested fix to test both overloads
     [Theory(DisableDiscoveryEnumeration = true)]
     [MemberData(nameof(TestConfiguration.TestDatabases), MemberType = typeof(TestConfiguration))]
     public async Task HashFieldGetAndSetExpiryAsync_MultiField_ThrowsOnCommandFlags(IDatabaseAsync db)
     {
         _ = await Assert.ThrowsAsync<NotImplementedException>(
-            () => db.HashFieldGetAndSetExpiryAsync("key", [], flags: UnsupportedFlag));
+            () => db.HashFieldGetAndSetExpiryAsync("key", new[] { new HashFieldExpiry("field", TimeSpan.Zero) }, flags: UnsupportedFlag));
         _ = await Assert.ThrowsAsync<NotImplementedException>(
-            () => db.HashFieldGetAndSetExpiryAsync("key", [], flags: UnsupportedFlag));
+            () => db.HashFieldGetAndSetExpiryAsync("key", new[] { new HashFieldExpiry("field", DateTime.MinValue) }, flags: UnsupportedFlag));
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/Valkey.Glide.IntegrationTests/StackExchange/CommandFlagsTests.cs`
around lines 421 - 427, The two assertions call the same overload of
HashFieldGetAndSetExpiryAsync; change the second assertion to exercise the
DateTime-based overload for multi-field operations so both overloads are
covered: keep the first assertion testing the TimeSpan-based overload (existing
call with UnsupportedFlag) and modify the second call to pass the DateTime
expiry overload variant for HashFieldGetAndSetExpiryAsync while still asserting
NotImplementedException and using the same test key, multi-field input, and
UnsupportedFlag.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@tests/Valkey.Glide.IntegrationTests/StackExchange/CommandFlagsTests.cs`:
- Around line 441-447: The two assertions in
HashFieldSetAndSetExpiryAsync_MultiField_ThrowsOnCommandFlags currently call the
same TimeSpan overload twice; update the second Assert.ThrowsAsync to call the
DateTime overload of HashFieldSetAndSetExpiryAsync so the test covers both
overloads (keep using the same key, empty field list and UnsupportedFlag),
referencing the IDatabaseAsync.HashFieldSetAndSetExpiryAsync(DateTime) signature
to ensure the DateTime-based overload is invoked.
- Around line 421-427: The two assertions call the same overload of
HashFieldGetAndSetExpiryAsync; change the second assertion to exercise the
DateTime-based overload for multi-field operations so both overloads are
covered: keep the first assertion testing the TimeSpan-based overload (existing
call with UnsupportedFlag) and modify the second call to pass the DateTime
expiry overload variant for HashFieldGetAndSetExpiryAsync while still asserting
NotImplementedException and using the same test key, multi-field input, and
UnsupportedFlag.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9237eb40-f7fc-42cd-a09c-f458d0ccfdaa

📥 Commits

Reviewing files that changed from the base of the PR and between bffb07d and 6c6c9fd.

📒 Files selected for processing (5)
  • AGENTS.md
  • DEVELOPER.md
  • Taskfile.yml
  • sources/Valkey.Glide/Abstract/ValkeyServer.cs
  • tests/Valkey.Glide.IntegrationTests/StackExchange/CommandFlagsTests.cs

currantw added 2 commits May 12, 2026 10:26
…ssertions

Without a prefix, FT.CREATE indexes scan all keys in the database.
When tests run in parallel, stray keys from other tests can be indexed,
causing attr.Size to be non-zero unexpectedly.

Adding a unique prefix (based on the index GUID) isolates each test's
index from other data in the database.

Signed-off-by: currantw <taylor.curran@improving.com>
…hash expiry

HashFieldGetAndSetExpiryAsync_MultiField and
HashFieldSetAndSetExpiryAsync_MultiField were calling the same
TimeSpan-based overload twice. The second assertion now calls the
DateTime-based overload to cover both signatures.

Signed-off-by: currantw <taylor.curran@improving.com>
Comment thread tests/Valkey.Glide.IntegrationTests/ServerModules/FtInfoTests.cs
… into currantw/254_add_missing_command_flags_tests

Signed-off-by: currantw <taylor.curran@improving.com>
@xShinnRyuu

xShinnRyuu commented May 12, 2026

Copy link
Copy Markdown
Collaborator

Cross referencing the list inf Issue #254, it looks like you may be missing some overloads

1. HyperLogLog Commands (6 overloads missing):
  - HyperLogLogAddAsync
  - HyperLogLogLengthAsync 
  - HyperLogLogMergeAsync

2. ChannelMessageQueue:
  - ChannelMessageQueue.UnsubscribeAsync

Signed-off-by: currantw <taylor.curran@improving.com>
@currantw

Copy link
Copy Markdown
Collaborator Author

Cross referencing the list inf Issue #254, it looks like you may be missing some overloads

1. HyperLogLog Commands (6 overloads missing):
  - HyperLogLogAddAsync
  - HyperLogLogLengthAsync 
  - HyperLogLogMergeAsync

2. ChannelMessageQueue:
  - ChannelMessageQueue.UnsubscribeAsync

Added test for ChannelMessageQueue.UnsubscribeAsync. HyperLogLog commands were refactored after I raised these – they are not part of StackExchange.Redis compatibility, so there are no CommandFlags anymore!

currantw added 4 commits May 12, 2026 13:56
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Signed-off-by: currantw <taylor.curran@improving.com>
Comment thread tests/Valkey.Glide.IntegrationTests/ClientSideCacheTests.cs
Comment thread tests/Valkey.Glide.IntegrationTests/ClientSideCacheTests.cs
@currantw
currantw enabled auto-merge (squash) May 12, 2026 21:41
@currantw
currantw merged commit 367b813 into valkey-io:main May 12, 2026
12 checks passed
@currantw
currantw deleted the currantw/254_add_missing_command_flags_tests branch May 12, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dev Internal changes like cleanup, refactoring, or developer tools. tests Unit tests, integration tests, or test utilities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add integration tests for all CommandFlags overloads

4 participants