hi in woremock, is there any helper like pickUniqu...
# general
p
hi in woremock, is there any helper like pickUnique similar to pickRandom. I want to pick the items from the array list, one by one uniquely, is that possible? {{#parseJson 'idList'}} ["x","y","z","a","b"] {{/parseJson}} I got all the ids in the idList, now i need to replace separate place something like, in 1st iteration id = "{{x}}" 2nd iteration it should be id="{{y}}" and so on. Can this be done?
l
Hi, sorry, I am not sure what it is you mean. Do you mean you want to iterate through the list? Could you explain what you mean when you say
replace separate place
?
r
i believe the
count
option on the
pickRandom
helper is what you're looking for.
{{pickRandom (array 1 2 3 4 5) count=3}}
will pick three unique items from the list at random
ill make a note to add this to the docs site
p
@Lee Turner, basically the requirement is if I have a list like ["1","2","3"], then it should pick the item uniquely /sequentially like in first iteration it picks 1, second iteration it pick 2 and 3rd iteration it picks 3. Currently with pickRandom, it is picking the values randomly and repeating many a times @Rafe Arnold, let me try your solution, looks like this may work
r
ive created a pr for the docs site here
p
@Lee Turner basically on each request it should return unique value
r
providing a different, unique value on each request would require persisting state between requests, which you might be able to achieve with out-of-the-box wiremock using scenarios. otherwise, the state extension could be the best way to achieve your goal
p
thanks every body, somehow I manage to add values like 0,1 and 2 -- etc with some predefined values and in every new request counter gets increased by one and making it a unique one, and solving the problem for time being