Skip to content

feat: added built-in mocking feature#16

Merged
petruki merged 1 commit into
masterfrom
staging
Jun 24, 2026
Merged

feat: added built-in mocking feature#16
petruki merged 1 commit into
masterfrom
staging

Conversation

@petruki

@petruki petruki commented Jun 24, 2026

Copy link
Copy Markdown
Member

This pull request introduces a comprehensive client-scoped mocking system to the Go SDK for Switcher, allowing feature flag results to be overridden in tests with fine-grained control. It adds a fluent API for defining mocks, conditional mocking based on strategies, metadata attachment, and automatic cleanup integration with Go's testing framework. The changes are well-documented in the README and thoroughly tested.

Mocking and Testability Enhancements:

  • Added a new mocking system to the Client via the Assume and Forget methods, allowing test code to override feature flag results per client instance. The fluent API supports forced true/false, conditional mocks based on strategies, metadata, and automatic cleanup registration. (mock.go, client.go, [1] [2] [3]
  • Integrated the mocking system into the main evaluation flow: Switcher.submit now checks for mocked results before normal evaluation. (switcher.go, switcher.goR180-R185)
  • Added a comprehensive test suite for the mocking system, covering forced results, conditional logic, metadata, cleanup, and interaction with the snapshot system. (mock_test.go, mock_test.goR1-R184)

Documentation Updates:

  • Updated the README to document the new mocking API, provide usage examples, and clarify that mocks are client-scoped. Removed outdated references to "Test Helpers (Under development)" and clarified the focus on mocking. (README.md, [1] [2] [3] [4]

@petruki petruki self-assigned this Jun 24, 2026
@petruki petruki added enhancement New feature or request ai-assisted Indicates that AI tools were used to assist this with this change ai-generated Indicates that AI tools were used to generate this change labels Jun 24, 2026
@sonarqubecloud

Copy link
Copy Markdown

@petruki petruki merged commit a0f50fd into master Jun 24, 2026
7 checks passed
@petruki petruki deleted the staging branch June 24, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Indicates that AI tools were used to assist this with this change ai-generated Indicates that AI tools were used to generate this change enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant