elliotchance / redismock

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

Add support of go-redis v8 #23

Closed meysampg closed 3 years ago

meysampg commented 3 years ago

The last version v7 could not be used to use with go-redis/v8. This PR will add support of this version to redismock.


This change is Reviewable

kbop543-zz commented 3 years ago

How can I get the new changes from this pr? I've updated using the go get -u flag and tried to import the v8 folder but none of that works.

I ran: go get -u github.com/elliotchance/redismock/v8 and got go get github.com/elliotchance/redismock/v8: module github.com/elliotchance/redismock@upgrade found (v1.5.3), but does not contain package github.com/elliotchance/redismock/v8

I also ran go get -u github.com/elliotchance/redismock and didn't get the updates in the pr.

elliotchance commented 3 years ago

Make sure your are using a recent version of Go (probably only 1.13+). The first command you tried is correct:

go get -u github.com/elliotchance/redismock/v8

Alternatively, if you are using Go modules (you have a go.mod file in your project) you should be able to put github.com/elliotchance/redismock/v8 as an import in your code and go build/go test will pull in the dependency for you.

kbop543-zz commented 3 years ago

I put the line github.com/elliotchance/redismock/v8 v8.0.0 in my go.mod file but when I build and run go mod vendor it says go: github.com/elliotchance/redismock/v8@v8.0.0: github.com/elliotchance/redismock/v8/go.mod has non-.../v8 module path "github.com/elliotchance/redismock" at revision v8.0.0. Not sure whats going on here..

I am also running go version 1.14.

elliotchance commented 3 years ago

That's bizarre. Even though @meysampg made the change to go.mod that change was not merged in. I have fixed it and retagged as v8.0.1. Let me know if that fixes it for you.

kbop543-zz commented 3 years ago

So I added the change github.com/elliotchance/redismock/v8 v8.0.1 and now it says go: github.com/elliotchance/redismock/v8@v8.0.1: github.com/elliotchance/redismock/go.mod and .../v8/go.mod both have .../v8 module paths at revision v8.0.1

It seems you have two go.mod files in your repo. One in the v8 folder and another outside of that in v1 I would presume. I think the v1 one added by @meysampg needs to be removed?

If I add github.com/elliotchance/redismock v1.8.0 to my go.mod, it says go: github.com/elliotchance/redismock@v1.8.0: go.mod has post-v1 module path "github.com/elliotchance/redismock/v8" at revision v1.8.0

elliotchance commented 3 years ago

Thanks! I've got a good feeling about this one: https://github.com/elliotchance/redismock/releases/tag/v8.0.2