Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add "mock_engine" feature to SDK to allow offline query testing #476

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

j-lanson
Copy link
Collaborator

@j-lanson j-lanson commented Oct 8, 2024

Resolves #431 .

Adds a feature flag to the Rust SDK called "mock_engine" that gates PluginEngine functionality and some imports.

Adds a field to the PluginEngine called mock_responses that contains a lookup table. When query() is called, if the "mock_engine" feature is enabled, it will use that table instead of querying out to the Hipcheck core. This allows us to test query logic without spinning up a whole Hipcheck analysis.

The SDK version of the rand_data plugin is updated to use the SDK macro system, and a test case has been added to demonstrate how plugins can be tested locally with mock_responses.

The cfg compiler flags have been carefully applied to ensure no "unused" warnings whether running with "mock_engine" or not.

I've temporarily left the commits split between what @patrickjcasey had done before he went on leave and what I have since added.

@j-lanson j-lanson added type: enhancement New feature or request product: rust-sdk Relates to the Rust plugin SDK labels Oct 8, 2024
@j-lanson j-lanson self-assigned this Oct 8, 2024
@j-lanson j-lanson added this to the 3.8.0 milestone Oct 8, 2024
@j-lanson j-lanson force-pushed the patrickjcasey/hipcheck-sdk-test-mock-reply branch from b5e9691 to 5af7177 Compare October 8, 2024 17:36
@j-lanson j-lanson force-pushed the patrickjcasey/hipcheck-sdk-test-mock-reply branch from 5af7177 to 0ba9a8b Compare October 10, 2024 16:56
@j-lanson
Copy link
Collaborator Author

Squashed

@j-lanson j-lanson merged commit fddb21f into main Oct 10, 2024
9 checks passed
@patrickjcasey patrickjcasey deleted the patrickjcasey/hipcheck-sdk-test-mock-reply branch October 18, 2024 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product: rust-sdk Relates to the Rust plugin SDK type: enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Rust SDK should include a test mechanism to mock out query responses
3 participants