AtlassianPS / JiraPS

PowerShell module to interact with Atlassian JIRA
https://AtlassianPS.org/module/JiraPS
MIT License
325 stars 131 forks source link

Add-JiraGroupMember Test not passing on Windows PWSH5, PWSH7 #425

Closed spascoe closed 3 years ago

spascoe commented 3 years ago

Description

Add-JiraGroupMember Test "User [@{Name=testUsername1}] is already a member of group [testGroup] is not succeeding on Windows, PWSH 5, and PWSH 7.

Steps To Reproduce

  1. Go to the Repo root folder
  2. If you haven't run the setup: .\tools\setup.ps1
  3. Invoke-Build
  4. The test described above fails.

Expected behavior

The test should pass

Screenshots

Executing script C:<redacted>\jiraps\Release\Tests\Functions\Add-JiraGroupMember.Unit.Tests.ps1

  Describing Add-JiraGroupMember

    Context Sanity checking

    Context Behavior testing
 User [@{Name=testUsername1}] is already a member of group [testGroup]      [-] Tests to see if a provided user is currently a member of the provided JIRA group before attempting to add them 247ms
        Expected an exception, to be thrown, but no exception was thrown.
        117:                 { Add-JiraGroupMember -Group $testGroupName -User $testUsername1 -ErrorAction Stop } | Should Throw
        at Invoke-LegacyAssertion, C:\Users\<redacted>\My > Documents\WindowsPowerShell\Modules\Pester\4.6.0\Functions\Assertions\Should.ps1: line 166

    Context Error checking
 User [@{Name=testUsername1}] is already a member of group [testGroup]

Your Environment

C:\> Get-Module JiraPS -ListAvailable | Select Name, Version

Name   Version
----   -------
jiraps 2.14.4

C:\> $psversiontable

Name                           Value
----                           -----
PSVersion                      5.1.16299.1146
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16299.1146
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Possible Solution

First, I'm looking to see if this is an issue on my machine, It looks like the ErrorAction Stop may not be causing a throw on error... Second, the Jira code is using "Write-Error" (The PWSH function) and not "WriteError" (the Private jiraPS Function). Not sure if this is the cause or not.