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

fix(sdk)!: don't allow duplicate mock expectations #1788

Merged
merged 14 commits into from
Mar 18, 2024

Conversation

lklimek
Copy link
Contributor

@lklimek lklimek commented Mar 18, 2024

Issue being fixed or feature implemented

Right now, when adding new expected request/response pair to rs-sdk / rs-dapi-client with the duplicate request, previous request is silently replaced. This can cause non-deterministic behavior, where test result depends on order in which expectations are added.

What was done?

Return error when duplicate expectation is created.

Separate test vectors from various tests into separate directories (namespaces) to avoid conflicts.

How Has This Been Tested?

Added unit tests.

Commented out code that deletes old test vectors. Then, called the following command 3 times, to generate conflicting test vectors:

./packages/rs-sdk/scripts/generate_test_vectors.sh document_read

Then started cargo test -p rs-sdk document_read to ensure it fails with MockExpectationConflict errors.

Breaking Changes

  • Adding duplicate mock expectation returns error
  • Changed structure of test vectors directory

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

@lklimek lklimek force-pushed the fix/mock-expectations-conflict branch from c1f249d to 4ae111d Compare March 18, 2024 17:00
@lklimek lklimek marked this pull request as ready for review March 18, 2024 17:00
@QuantumExplorer QuantumExplorer merged commit faefb58 into v1.0-dev Mar 18, 2024
31 checks passed
@QuantumExplorer QuantumExplorer deleted the fix/mock-expectations-conflict branch March 18, 2024 23:29
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.

2 participants