Why does the following test fail with go-redis v9 but not with v8? t.Run("returns 0 when…
- User
Why does the following test fail with go-redis v9 but not with v8?
t.Run("returns 0 when key does not exist", func(t *testing.T) { id := "5cd4bf2f6d78f205078bc572" wantAKey := fmt.Sprintf("x:{%s}:y:total", id) wantBKey := fmt.Sprintf("x:{%s}:y:%s:daily", id, todayDate) wantCKey := fmt.Sprintf("x:{%s}:y:%s:daily:countries", id, todayDate) mock.ExpectGet(wantAKey).RedisNil() mock.ExpectGet(wantBKey).RedisNil() mock.ExpectHGetAll(wantCKey).RedisNil() got, err := storage.Get(ctx, id, pkg.TypeX) require.NoError(t, err) require.Equal(t, &result.Result{ id, pkg.TypeX, 0, 0, map[string]float64{}, }, got) mock.ClearExpect() }) - Assistant
It is not possible to identify the exact cause of the failure without more context, such as the actual implementation of the
storage.Getfunction and the error message from the failing test. However, there are some possible reasons for it to fail with go-redis v9 compared to v8:-
API changes: Some APIs and function signatures might have changed between go-redis v8 and v9. Check the documentation and release notes for any breaking changes that might have been introduced in v9. It could also be possible that a bug fixed in v9 caused the test to pass in v8 due to the unintended behavior. Update your code to use the correct version and verify that the mock expectations match the updated code.
-