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

Avoid using unexported constants in tests #485

Merged
merged 14 commits into from
Jan 30, 2025

Conversation

fxamacker
Copy link
Member

@fxamacker fxamacker commented Jan 24, 2025

Updates #464

This PR avoids using these unexported constants in tests:

  • minInternalCBORTagNumber
  • maxInternalCBORTagNumber
  • maxInlineArrayElementSize
  • maxInlineMapElementSize
  • maxInlineMapKeySize
  • targetThreshold

  • Targeted PR against main branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

Currently, some tests are using unexported fields of
PersistentSlabStorage.

This commit improves decoupling:
- in storage.go, create unexported functions for those fields
- in export_test.go, export those unexported functions in same package,
so those exported functions can be used for testing in test package.
- modify tests to use the newly exported functions.
This commit avoids using these unexported constants in tests:
- minInternalCBORTagNumber
- maxInternalCBORTagNumber
@fxamacker fxamacker self-assigned this Jan 24, 2025
@fxamacker fxamacker requested a review from turbolent as a code owner January 24, 2025 17:03
This commit avoids using maxInlineArrayElementSize in tests.
This commit avoids using maxInlineMapKeySize in tests.
This commit adds new function MaxInlineMapElementSize() and
modifies tests to use the new function instead of unexported
constants maxInlineMapElementSize.
This commit:
- adds new function targetSlabSize() in settings.go
- exports targetSlabSize() to TargetSlabSize() in export_test.go
  for testing
- modifies tests to use exported function instead of unexported
constants targetThreshold.
@fxamacker fxamacker force-pushed the fxamacker/avoid-accessing-SlabID-fields-in-tests branch from 4c4b64c to 331eea6 Compare January 28, 2025 18:50
@fxamacker fxamacker changed the base branch from fxamacker/avoid-accessing-SlabID-fields-in-tests to main January 28, 2025 20:05
@fxamacker
Copy link
Member Author

@turbolent Can you review and approve this PR? Other refactor PRs are blocked by this.

I'll resolve conflicts after I merge all other refactor PRs to this PR so I only need to resolve conflicts once.

…rayDataSlab-directly-in-tests

Avoid creating ArrayDataSlab directly in tests
…map-fields-in-tests

Avoid using unexported `OrderedMap` fields in tests
…Array-root-field-in-tests

Avoid using unexported `Array` fields in tests
@fxamacker fxamacker merged commit 43daff8 into main Jan 30, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants