LightningFlowComponents
LightningFlowComponents copied to clipboard
*GetGroupInfo* - _(GetGroupInfoTest.cls)_ - Assertion fails when query results order changes due to external triggers on user
How to use GitHub
- Please use the 👍 reaction to show that you are affected by the same issue.
- Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
- Subscribe to receive notifications on status change and new comments.
Steps to reproduce
Steps to reproduce the behavior:
- Build additional automation on User that causes modification to user with alias='user2'. This may change the order of results returned by
SELECT User.Id, User.Email, User.Username FROM User WHERE Id IN (SELECT UserOrGroupId FROM GroupMember WHERE GroupId = :groupId)]
in GetGroupInfo.analyzeGroup() - Run test canGetGroupInfo() in GetGroupInfoTest
Expected behaviour
Test method assertions should pass
Actual behaviour
if the GetGroupInfo.get() query returns the users in a different order than they were inserted, the assertions fail
Proposed Solution
In GetGroupInfoTest.cls, replace
List<User> resultUsers = results[0].users;
System.assertEquals(resultUsers[0].Id, inputUsers[0].Id);
System.assertEquals(resultUsers[1].Id, inputUsers[1].Id);
with
Map<Id,User> resultUsers = new Map<Id,User> (results[0].users);
System.assert(resultUsers.containsKey(inputUsers[0].id));
System.assert(resultUsers.containsKey(inputUsers[1].id));
Thanks, @jimletts .... I'd be happy to take this change as a pull request, if you'd like to create one.