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

How to test command redis 'SetArgs' #24

Closed
bas80836255 opened this issue Jan 26, 2022 · 1 comment
Closed

How to test command redis 'SetArgs' #24

bas80836255 opened this issue Jan 26, 2022 · 1 comment

Comments

@bas80836255
Copy link

bas80836255 commented Jan 26, 2022

my production code is

setArgs := redis.SetArgs{
  ExpireAt: time.UnixMilli(minTime),
  }
setCmd := c.redis.SetArgs(ctx, "counter_slug_pause_ssoid_day, "1", setArgs)

and in unit test is

clientMock.CustomMatch(func(expected, actual []interface{}) error {
		assert.Equal(t.T(), expected[0], actual[0])
		assert.Equal(t.T(), expected[1], actual[1])
		assert.Equal(t.T(), expected[2], actual[2])
		assert.Equal(t.T(), "paxt", actual[3])
		return nil
	}).ExpectSet("counter_slug_pause_ssoid_day, "1", 0).SetVal("ok")

when run found error
parameters do not match, expectation '[set counter_slug_pause_ssoid_day 1]', but call to cmd '[set counter_slug_pause_ssoid_day 1 exat 0]'

what is the best way to stub 'SetArgs' command

@agammell
Copy link

I've opened a PR to address this as I hit the same issue: #34

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