We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hello team I getting below error cannot use redismock.NewClientMock() (value of type *redis.Client) as redis.Cmdable value in assignment
cannot use redismock.NewClientMock() (value of type *redis.Client) as redis.Cmdable value in assignment
For the code below redis.go `package redis
import ( "fmt" "time"
"github.com/go-redis/redis"
)
type redisConn struct { host string port string password string client *redis.Client }
const ( redisPwd = "" redisPort = "6379" )
// RedisNewConn func (r redisConn) RedisNewConn() error {
r.client = redis.NewClient(&redis.Options{ Addr: r.host + ":" + r.port, Password: r.password, }) if r.client == nil { return fmt.Errorf("redis Connection failed") } if _, err := r.client.Ping().Result(); err != nil { return err } return nil
}
// Set func (r redisConn) Set(k string, d string, expiry time.Duration) error {
err := r.client.Set(k, d, expiry).Err() if err != nil { return err } return nil
// Get func (r redisConn) Get(k string) (string, error) {
d, e := r.client.Get(k).Result() if e != nil { return "", e } return d, nil
} redis_test.gopackage redis
redis_test.go
import ( "testing"
"[github.com/go-redis/redis](http://github.com/go-redis/redis)" "[github.com/go-redis/redismock/v8](http://github.com/go-redis/redismock/v8)"
type mockRedis struct { key string val string client *redis.Client }
func TestGet(t *testing.T) {
var conn redisConn var mock redismock.ClientMock conn.client, mock = redismock.NewClientMock() mockr := mockRedis{key: "news_redis_cache_123456", val: "s"} mock.ExpectGet(mockr.key).SetVal(mockr.val)
}`
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hello team I getting below error
cannot use redismock.NewClientMock() (value of type *redis.Client) as redis.Cmdable value in assignment
For the code below
redis.go
`package redis
import (
"fmt"
"time"
)
type redisConn struct {
host string
port string
password string
client *redis.Client
}
const (
redisPwd = ""
redisPort = "6379"
)
// RedisNewConn
func (r redisConn) RedisNewConn() error {
}
// Set
func (r redisConn) Set(k string, d string, expiry time.Duration) error {
}
// Get
func (r redisConn) Get(k string) (string, error) {
}
redis_test.go
package redisimport (
"testing"
)
type mockRedis struct {
key string
val string
client *redis.Client
}
func TestGet(t *testing.T) {
}`
The text was updated successfully, but these errors were encountered: