Skip to content

Add missing SetWithTTL method to MockStateManagerContext - #835

Open
pujitha24 wants to merge 1 commit into
dapr:mainfrom
pujitha24:auto/issue-548
Open

pujitha24 wants to merge 1 commit into
dapr:mainfrom
pujitha24:auto/issue-548

Conversation

@pujitha24

Copy link
Copy Markdown

Motivation:
Issue #548 asks for actor TTL support. Actor state TTL is already
implemented (SetWithTTL on actor.StateManagerContext, wired through to
Dapr's ActorStateOperation.TTLInSeconds), and reminder/timer TTL has
existed since 2021. However, actor/mock/mock_server.go — a MockGen
generated mock of the interfaces in actor/actor.go — was never
regenerated after SetWithTTL was added to StateManagerContext. As a
result MockStateManagerContext silently did not implement
actor.StateManagerContext, defeating the purpose of the mock for any
test that needs to stub the full interface (e.g. to unit test actor
code that calls SetWithTTL).

No existing code in the repo currently assigns a *MockStateManagerContext
to an actor.StateManagerContext-typed variable, so this did not break
any existing build or test. The fix only restores the mock's fidelity
to its source interface; it does not change any runtime behavior.

Approach:

  • Add the missing SetWithTTL method (and its recorder) to
    MockStateManagerContext in actor/mock/mock_server.go, matching the
    exact style of the other generated methods in that file.
  • Add actor/mock/mock_server_test.go with a compile-time assertion
    (var _ actor.StateManagerContext = (*MockStateManagerContext)(nil))
    so a future interface change that isn't reflected in the mock fails
    to build instead of failing silently, plus a small gomock-based test
    exercising the new method.

Validation:

  • go build ./... (passes)
  • go test ./actor/... (passes, including the new
    TestMockStateManagerContextSetWithTTL)
  • gofmt -l on both changed files reports no diffs

Fixes #548

Signed-off-by: Pujitha Paladugu 10557236+pujitha24@users.noreply.github.com

Motivation:
Issue dapr#548 asks for actor TTL support. Actor state TTL is already
implemented (SetWithTTL on actor.StateManagerContext, wired through to
Dapr's ActorStateOperation.TTLInSeconds), and reminder/timer TTL has
existed since 2021. However, actor/mock/mock_server.go — a MockGen
generated mock of the interfaces in actor/actor.go — was never
regenerated after SetWithTTL was added to StateManagerContext. As a
result MockStateManagerContext silently did not implement
actor.StateManagerContext, defeating the purpose of the mock for any
test that needs to stub the full interface (e.g. to unit test actor
code that calls SetWithTTL).

No existing code in the repo currently assigns a *MockStateManagerContext
to an actor.StateManagerContext-typed variable, so this did not break
any existing build or test. The fix only restores the mock's fidelity
to its source interface; it does not change any runtime behavior.

Approach:
- Add the missing SetWithTTL method (and its recorder) to
  MockStateManagerContext in actor/mock/mock_server.go, matching the
  exact style of the other generated methods in that file.
- Add actor/mock/mock_server_test.go with a compile-time assertion
  (var _ actor.StateManagerContext = (*MockStateManagerContext)(nil))
  so a future interface change that isn't reflected in the mock fails
  to build instead of failing silently, plus a small gomock-based test
  exercising the new method.

Validation:
- go build ./...  (passes)
- go test ./actor/...  (passes, including the new
  TestMockStateManagerContextSetWithTTL)
- gofmt -l on both changed files reports no diffs

Fixes dapr#548

Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
@pujitha24
pujitha24 requested a review from a team as a code owner July 30, 2026 00:22
Copilot AI review requested due to automatic review settings July 30, 2026 00:22
@pujitha24
pujitha24 requested a review from a team as a code owner July 30, 2026 00:22

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@pujitha24

Copy link
Copy Markdown
Author

This has been sitting for a bit and is still green and rebased — happy to make any changes if something would help move review along.

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.

Add support for Actor TTL

3 participants