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

add nop store #126

Merged
merged 4 commits into from
Oct 31, 2023
Merged

add nop store #126

merged 4 commits into from
Oct 31, 2023

Conversation

peczenyj
Copy link
Contributor

Hello

In some scenarios it is interesting add an object that does nothing (for testing, debug, etc)

for instance, imagine I may use one of few different implementations of govk.Store and I decide it based on configuration using some strategy pattern. To test the application without the govk.Store I had two options:

  1. use a nil store and add several if store != nil {... } around the code, or
  2. I had to implement a nop interface by myself

not anymore!

This also perform the validation of key / value like a regular gokv.Store does, to avoid break compatibility.

If you want, I can add an option to disable this validation

Enjoy

@philippgille
Copy link
Owner

Hi, thanks a lot! I'll have a look on Tuesday.

Copy link
Owner

@philippgille philippgille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for your contribution!

Two comments, but not blockers.

nop/nop_test.go Outdated
t.Helper()

if err == nil {
t.Error("expect error, got nil")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker, but checking all other *_test.go files in this repo, they use either "Expected an error" or "An error was expected". The exact phrasing doesn't matter, but I'd suggest uppercase and past tense for consistency, e.g.

Suggested change
t.Error("expect error, got nil")
t.Error("Expected error, got nil")

Errors are usually lowercase as they can be chained in a log message (e.g. "couldn't x: failed to y: ...", but here it's a log message and not an error that might be chained, where I like the differentiation.

Again, totally not a blocker though.

nop/docs.go Outdated Show resolved Hide resolved
Signed-off-by: Tiago Peczenyj <tpeczenyj@weborama.com>
Copy link
Owner

@philippgille philippgille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the change 💪

@philippgille philippgille merged commit 672740b into philippgille:master Oct 31, 2023
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