-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xGroup: Ensure group members are always returned as an array (#701)
* xGroup: Ensure group members are always returned as an array PowerShell will unpack single element arrays on function return by default. That's problematic when we explicitly expect an array. Note that prefixing the return operation in Get-MembersOnFullSKU and Get-MembersOnNanoServer with ',' to indicate the array should not be unrolled introduces separate issues as the underlying mechanism will wrap the "inner" array in an "outer" array, the latter being unpacked automatically when passed down the pipeline. That means: - Pester tests will fail when no group members are expected as it will encounter an empty array (the "inner" array) instead of $null. - Pester tests will fail on testing expected group members as it will encounter an array (the "inner" array) instead of the enumerated members from the result passed down the pipeline. Both of the above are known Pester issues (see Pester Issue #1154). We could update the tests, but behind the scenes Pester is complaining about a change in returned data types, and that feels problematic. So instead check if the returned data is a string (indicating a single group member) and convert it to an object array if so. * xGroup: Add additional unit tests to verify single member behaviour This introduces two new tests which verify the expected behaviour on returning the members of a group which has a single member (a single element array). One test is for Nano server and the other for the full SKU as they have different codepaths. The existing two group member tests are renamed to explicitly reflect they're checking behaviour on returning a group with multiple members. * Merge branch 'master' into xgroup-preserve-members-array
- Loading branch information
Showing
3 changed files
with
63 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters