test(memstore): add tests for Store operations and Entry conversions - #2607
Open
Qalipso wants to merge 1 commit into
Open
test(memstore): add tests for Store operations and Entry conversions#2607Qalipso wants to merge 1 commit into
Qalipso wants to merge 1 commit into
Conversation
core/memstore was at 11.0% statement coverage. This covers the Store CRUD surface (Set/Get/GetEntry/GetEntryAt/Remove/Reset/Len/Visit/ GetOrSet), immutability semantics, the Entry type conversions and their error paths, ErrEntryNotFound matching, and the sized integer and float getters including out-of-range rejection. Coverage goes from 11.0% to 59.2%. No non-test code is changed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
core/memstoreis at 11.0% statement coverage. It is a self-contained, dependency-free package, so it is straightforward to cover.This adds tests for:
Storesurface:Set,Get,GetDefault,GetEntry,GetEntryAt,Exists,Remove,Reset,Len,Visit,GetOrSetSave(the returned boolean)SetImmutableentries reject a plainSetbut accept anotherSetImmutableEntryconversions and their error paths:StringDefault,StringTrim,IntDefault,BoolDefault,TimeDefault,WeekdayDefault,Float64DefaultErrEntryNotFoundformatting andAsmatching, including viaerrors.AsCoverage goes from 11.0% to 59.2%. No non-test code is changed;
go vetandgo test -racepass.While writing these I ran into what looks like a bug in
UintDefault, so I left it uncovered rather than encode the current behaviour in a test:On a 64-bit platform
maxValueismath.MaxUint64, so the conversionint(maxValue)wraps to-1. The comparison becomesvv > -1, which is true for every positiveint, soUintDefaultreturns the default and a not-found error for any plainintvalue:The sized variants (
Uint8Defaultand friends) use literal bounds and are not affected. Happy to send a separate PR for it if you'd like — I did not want to mix a behaviour change into a test-only PR.