elliotchance / redismock

🕋 Mocking Redis in unit tests in Go.
MIT License
147 stars 24 forks source link

Support Redis v7 #18

Closed BatuhanKucukali closed 4 years ago

BatuhanKucukali commented 4 years ago

Hi

How can I use v7 redis client for mock.

go get github.com/elliotchance/redismock

Result:

Screen Shot 2020-05-20 at 21 24 49
elliotchance commented 4 years ago

Sorry, I forgot to add the release tag. Try now

BatuhanKucukali commented 4 years ago

go get github.com/elliotchance/redismock@v7

Result: go get github.com/elliotchance/redismock@v7: no matching versions for query "v7"`

go get github.com/elliotchance/redismock@v7.0.0

Result: go get github.com/elliotchance/redismock@v7.0.0: github.com/elliotchance/redismock@v7.0.0: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v7

go get github.com/elliotchance/redismock

Result: go: github.com/elliotchance/redismock upgrade => v1.5.3

haakonmo commented 4 years ago

From https://golang.org/cmd/go/#hdr-Module_compatibility_and_semantic_versioning

In semantic versioning, changing the major version number indicates a 
lack of backwards compatibility with earlier versions. To preserve import 
compatibility, the go command requires that modules with major version 
v2 or later use a module path with that major version as the final element. 
For example, version v2.0.0 of example.com/m must instead use module 
path example.com/m/v2, and packages in that module would use that path 
as their import path prefix, as in example.com/m/v2/sub/pkg. Including the 
major version number in the module path and import paths in this way is 
called "semantic import versioning". Pseudo-versions for modules with 
major version v2 and later begin with that major version instead of v0, 
as in v2.0.0-20180326061214-4fc5987536ef.

-> go get github.com/elliotchance/redismock/v7

haakonmo commented 4 years ago

I'm having issues as well due to the version change. On go get github.com/elliotchance/redismock/v7 Result:

go get github.com/elliotchance/redismock/v7: module 
github.com/elliotchance/redismock@upgrade found (v1.5.3), but does not contain package 
github.com/elliotchance/redismock/v7

And when manually defining github.com/elliotchance/redismock/v7 v7.0.0 in go.mod file and running go mod tidy then

github.com/elliotchance/redismock/v7@v7.0.0: go.mod has non-.../v7 module path 
"github.com/elliotchance/redismock" (and .../v7/go.mod does not exist) at revision v7.0.0

Maybe there have to exist a go.mod file in v7 folder?

Temporary solution for me is go get github.com/elliotchance/redismock/v7@master

johannesvietze commented 4 years ago

Hi Elliot,

there's a go.mod file missing in the v7-subdirectory. Also, you need to adapt the import path of that new go.mod file to github.com/elliotchance/redismock/v7

See here: https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher

elliotchance commented 4 years ago

Thanks @warijo. I have merged in #20 which should fix the issue.