Skip to content
\n

the probelm

\n
expected call at /go/clan-service/repository/redis_reserved_name_test.go:25 doesn't match the argument at index 1.\n        Got: index 1 redis command [SET test::clan::reservedname::my_name 69 NX EX 120]\n        Want: redis command [SET test::clan::reservedname::my_name 69 NX EX 120]\n
\n

the code under test

\n
qualifiedRequestedName := fmt.Sprintf(\"%s::clan::reservedname::%s\", r.env, requestedName)\n\n// Check if the key (the requested name) already exists in redis, if not set it with TTL\nuserStr := strconv.FormatInt(int64(userID), 10)\nsetnxCmd := r.client.B().Set().Key(qualifiedRequestedName).Value(userStr).Nx().ExSeconds(reservationTTLSec).Build()\ndidSet, err := r.client.Do(ctx, setnxCmd).ToInt64()\n
\n

How do I expect a index 1 redis command rather than a plain old redis command or am I barking up the wrong tree entirely?

\n

Many thanks.

","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"

Hi @tom-lkwd,

\n

Please try mock.Match(\"SET\", \"test::clan::reservedname::my_name\", \"69\", \"NX\", \"EX\", \"120\")

","upvoteCount":2,"url":"https://github.com/redis/rueidis/discussions/516#discussioncomment-8904200"}}}

client.EXPECT().Do(...) is expecting something unexpected #516

Answered by rueian
tom-lkwd asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @tom-lkwd,

Please try mock.Match("SET", "test::clan::reservedname::my_name", "69", "NX", "EX", "120")

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tom-lkwd
Comment options

Answer selected by tom-lkwd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants