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

Type issues with v9.0.3 and cache v9 #83

Open
Goldziher opened this issue Sep 21, 2023 · 2 comments
Open

Type issues with v9.0.3 and cache v9 #83

Goldziher opened this issue Sep 21, 2023 · 2 comments

Comments

@Goldziher
Copy link

Hi there,

Given the following dependencies (from go.mod):

	github.com/go-redis/cache/v9 v9.0.0
	github.com/go-redis/redismock/v9 v9.0.3

I get this issue:

# github.com/go-redis/redismock/v9
../../../go/pkg/mod/github.com/go-redis/redismock/[email protected]/mock.go:905:20: m.factory.GetBit undefined (type redis.Cmdable has no field or method GetBit)
../../../go/pkg/mod/github.com/go-redis/redismock/[email protected]/mock.go:912:20: m.factory.SetBit undefined (type redis.Cmdable has no field or method SetBit)
../../../go/pkg/mod/github.com/go-redis/redismock/[email protected]/mock.go:919:20: m.factory.BitCount undefined (type redis.Cmdable has no field or method BitCount)
../../../go/pkg/mod/github.com/go-redis/redismock/[email protected]/mock.go:926:20: m.factory.BitOpAnd undefined (type redis.Cmdable has no field or method BitOpAnd)
../../../go/pkg/mod/github.com/go-redis/redismock/[email protected]/mock.go:933:20: m.factory.BitOpOr undefined (type redis.Cmdable has no field or method BitOpOr)
../../../go/pkg/mod/github.com/go-redis/redismock/[email protected]/mock.go:940:20: m.factory.BitOpXor undefined (type redis.Cmdable has no field or method BitOpXor)
../../../go/pkg/mod/github.com/go-redis/redismock/[email protected]/mock.go:947:20: m.factory.BitOpNot undefined (type redis.Cmdable has no field or method BitOpNot)
../../../go/pkg/mod/github.com/go-redis/redismock/[email protected]/mock.go:954:20: m.factory.BitPos undefined (type redis.Cmdable has no field or method BitPos)
../../../go/pkg/mod/github.com/go-redis/redismock/[email protected]/mock.go:961:20: m.factory.BitPosSpan undefined (type redis.Cmdable has no field or method BitPosSpan)
../../../go/pkg/mod/github.com/go-redis/redismock/[email protected]/mock.go:968:20: m.factory.BitField undefined (type redis.Cmdable has no field or method BitField)
../../../go/pkg/mod/github.com/go-redis/redismock/[email protected]/mock.go:968:20: too many errors

I am executing the following test:

t.Run("Caches values as expected", func(t *testing.T) {
		_, err := rediscache.New("redis://redis:6379")
		assert.Nil(t, err)

		db, mockRedis := redismock.NewClientMock() //nolint: typecheck

		rediscache.SetClient(cache.New(&cache.Options{
			Redis: db,
		}))

		client := rediscache.GetClient()

		key := "john"

		val := &cache.Item{
			TTL:   time.Minute,
			Key:   key,
			Value: "doe",
		}

		expected, _ := client.Marshal("doe")

		mockRedis.ExpectSet(key, expected, time.Minute).SetVal("OK")
		setErr := client.Set(val)
		assert.NoError(t, setErr)
	})
@snoepkast
Copy link

This is caused by a new release of go-redis which was released yesterday.
By downgrading to v9.1.0 the issue is fixed, however an update to redismock would be nice.

@bertold
Copy link

bertold commented Sep 25, 2023

I added a PR to address this: https://github.com/go-redis/redismock/pull/84/files . This is my first contribution, so excuse me if I missed anything.

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

3 participants