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

Don't hit Redis on unit tests #3

Open
nhocki opened this issue Nov 20, 2015 · 1 comment
Open

Don't hit Redis on unit tests #3

nhocki opened this issue Nov 20, 2015 · 1 comment

Comments

@nhocki
Copy link
Owner

nhocki commented Nov 20, 2015

Right now we're hitting Redis on the radix/wrapper tests. I tried really hard to not do that and failed. I want something like this:

// wrappers/radix/wrapper.go

import "github.com/fzzy/radix/redis"

type radix interface {
    Cmd(command string, args ...interface{}) radixResponse
}

type radixResponse interface {
    Int64() (int64, error)
    List() ([]string, error)
}

// Client that implements the proximity.Client interface
type Client struct {
    client radix
}

But for some reason this doesn't work. It says that redis.Client doesn't implement the radix interface because the Cmd method returns a *redis.Reply. But redis.Reply implements bot Int64() and List() so I have no idea what I'm doing wrong.

If we can get this to work, we'll only Redis to be running for integration tests and I'd be really happy.

@bithavoc
Copy link

you need to return an instance/pointer of struct Reply, like this:

return &Reply{};

since Reply is not an interface but an struct, even if you implement radixResponse exactly as struct Reply you won´t be able to supply an instance of rafixResponse where an instance of Reply is expected.

I´m afraid your mock interface for the redis client would need to return an instance of struct Reply somehow.

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

No branches or pull requests

2 participants