2020-05-12 20:41:34 +03:00
|
|
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
# Licensed under the MIT License.
|
|
|
|
|
|
|
|
<#
|
|
|
|
.Synopsis
|
|
|
|
Tests for GitHubProjectCards.ps1 module
|
|
|
|
#>
|
|
|
|
|
|
|
|
# This is common test code setup logic for all Pester test files
|
|
|
|
$moduleRootPath = Split-Path -Path $PSScriptRoot -Parent
|
|
|
|
. (Join-Path -Path $moduleRootPath -ChildPath 'Tests\Common.ps1')
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
# Define Script-scoped, readOnly, hidden variables.
|
|
|
|
@{
|
|
|
|
defaultProject = "TestProject_$([Guid]::NewGuid().Guid)"
|
|
|
|
defaultColumn = "TestColumn"
|
|
|
|
defaultColumnTwo = "TestColumnTwo"
|
|
|
|
|
|
|
|
defaultCard = "TestCard"
|
|
|
|
defaultCardTwo = "TestCardTwo"
|
|
|
|
defaultCardUpdated = "TestCard_Updated"
|
|
|
|
defaultArchivedCard = "TestCard_Archived"
|
|
|
|
|
|
|
|
defaultIssue = "TestIssue"
|
|
|
|
}.GetEnumerator() | ForEach-Object {
|
|
|
|
Set-Variable -Force -Scope Script -Option ReadOnly -Visibility Private -Name $_.Key -Value $_.Value
|
|
|
|
}
|
|
|
|
|
|
|
|
$repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit
|
|
|
|
$project = New-GitHubProject -Owner $script:ownerName -Repository $repo.name -Name $defaultProject
|
|
|
|
|
|
|
|
$column = New-GitHubProjectColumn -Project $project.id -Name $defaultColumn
|
|
|
|
$columntwo = New-GitHubProjectColumn -Project $project.id -Name $defaultColumnTwo
|
|
|
|
|
|
|
|
$issue = New-GitHubIssue -Owner $script:ownerName -RepositoryName $repo.name -Title $defaultIssue
|
|
|
|
|
|
|
|
Describe 'Getting Project Cards' {
|
|
|
|
BeforeAll {
|
|
|
|
$card = New-GitHubProjectCard -Column $column.id -Note $defaultCard
|
|
|
|
$cardArchived = New-GitHubProjectCard -Column $column.id -Note $defaultArchivedCard
|
|
|
|
$null = Set-GitHubProjectCard -Card $cardArchived.id -Archive
|
2020-05-26 18:01:17 +03:00
|
|
|
|
|
|
|
# Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments
|
|
|
|
$card = $card
|
|
|
|
$cardArchived = $cardArchived
|
2020-05-12 20:41:34 +03:00
|
|
|
}
|
2020-05-26 18:01:17 +03:00
|
|
|
|
2020-05-12 20:41:34 +03:00
|
|
|
AfterAll {
|
|
|
|
$null = Remove-GitHubProjectCard -Card $card.id -Confirm:$false
|
|
|
|
}
|
|
|
|
|
|
|
|
Context 'Get cards for a column' {
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$results = @(Get-GitHubProjectCard -Column $column.id)
|
2020-05-12 20:41:34 +03:00
|
|
|
It 'Should get cards' {
|
|
|
|
$results | Should Not BeNullOrEmpty
|
|
|
|
}
|
|
|
|
|
|
|
|
It 'Note is correct' {
|
|
|
|
$results.note | Should be $defaultCard
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Context 'Get all cards for a column' {
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$results = @(Get-GitHubProjectCard -Column $column.id -ArchivedState All)
|
2020-05-12 20:41:34 +03:00
|
|
|
It 'Should get all cards' {
|
|
|
|
$results.Count | Should Be 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Context 'Get archived cards for a column' {
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$result = Get-GitHubProjectCard -Column $column.id -ArchivedState Archived
|
2020-05-12 20:41:34 +03:00
|
|
|
It 'Should get archived card' {
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$result | Should Not BeNullOrEmpty
|
2020-05-12 20:41:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
It 'Note is correct' {
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$result.note | Should be $defaultArchivedCard
|
2020-05-12 20:41:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
It 'Should be archived' {
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$result.Archived | Should be $true
|
2020-05-12 20:41:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Describe 'Modify card' {
|
|
|
|
BeforeAll {
|
|
|
|
$card = New-GitHubProjectCard -Column $column.id -Note $defaultCard
|
|
|
|
$cardTwo = New-GitHubProjectCard -Column $column.id -Note $defaultCardTwo
|
|
|
|
$cardArchived = New-GitHubProjectCard -Column $column.id -Note $defaultArchivedCard
|
2020-05-26 18:01:17 +03:00
|
|
|
|
|
|
|
# Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments
|
|
|
|
$card = $card
|
|
|
|
$cardTwo = $cardTwo
|
|
|
|
$cardArchived = $cardArchived
|
2020-05-12 20:41:34 +03:00
|
|
|
}
|
2020-05-26 18:01:17 +03:00
|
|
|
|
2020-05-12 20:41:34 +03:00
|
|
|
AfterAll {
|
2020-06-10 17:59:23 +03:00
|
|
|
$null = Remove-GitHubProjectCard -Card $card.id -Force
|
2020-05-12 20:41:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Context 'Modify card note' {
|
|
|
|
$null = Set-GitHubProjectCard -Card $card.id -Note $defaultCardUpdated
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$result = Get-GitHubProjectCard -Card $card.id
|
2020-05-12 20:41:34 +03:00
|
|
|
|
|
|
|
It 'Should get card' {
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$result | Should Not BeNullOrEmpty
|
2020-05-12 20:41:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
It 'Note has been updated' {
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$result.note | Should be $defaultCardUpdated
|
2020-05-12 20:41:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Context 'Archive a card' {
|
|
|
|
$null = Set-GitHubProjectCard -Card $cardArchived.id -Archive
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$result = Get-GitHubProjectCard -Card $cardArchived.id
|
2020-05-12 20:41:34 +03:00
|
|
|
|
|
|
|
It 'Should get card' {
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$result | Should Not BeNullOrEmpty
|
2020-05-12 20:41:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
It 'Card is archived' {
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$result.Archived | Should be $true
|
2020-05-12 20:41:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Context 'Restore a card' {
|
|
|
|
$null = Set-GitHubProjectCard -Card $cardArchived.id -Restore
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$result = Get-GitHubProjectCard -Card $cardArchived.id
|
2020-05-12 20:41:34 +03:00
|
|
|
|
|
|
|
It 'Should get card' {
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$result | Should Not BeNullOrEmpty
|
2020-05-12 20:41:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
It 'Card is not archived' {
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$result.Archived | Should be $false
|
2020-05-12 20:41:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Context 'Move card position within column' {
|
|
|
|
$null = Move-GitHubProjectCard -Card $cardTwo.id -Top
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$results = @(Get-GitHubProjectCard -Column $column.id)
|
2020-05-12 20:41:34 +03:00
|
|
|
|
|
|
|
It 'Card is now top' {
|
|
|
|
$results[0].note | Should be $defaultCardTwo
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Context 'Move card using after parameter' {
|
|
|
|
$null = Move-GitHubProjectCard -Card $cardTwo.id -After $card.id
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$results = @(Get-GitHubProjectCard -Column $column.id)
|
2020-05-12 20:41:34 +03:00
|
|
|
|
|
|
|
It 'Card now exists in new column' {
|
|
|
|
$results[1].note | Should be $defaultCardTwo
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Context 'Move card to another column' {
|
|
|
|
$null = Move-GitHubProjectCard -Card $cardTwo.id -Top -ColumnId $columnTwo.id
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$results = @(Get-GitHubProjectCard -Column $columnTwo.id)
|
2020-05-12 20:41:34 +03:00
|
|
|
|
|
|
|
It 'Card now exists in new column' {
|
|
|
|
$results[0].note | Should be $defaultCardTwo
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Context 'Move command throws appropriate error' {
|
|
|
|
It 'Appropriate error is thrown' {
|
|
|
|
{ Move-GitHubProjectCard -Card $cardTwo.id -Top -Bottom } | Should Throw 'You must use one (and only one) of the parameters Top, Bottom or After.'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Describe 'Create Project Cards' -tag new {
|
|
|
|
Context 'Create project card with note' {
|
|
|
|
BeforeAll {
|
|
|
|
$card = @{id = 0}
|
2020-05-26 18:01:17 +03:00
|
|
|
|
|
|
|
# Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments
|
|
|
|
$card = $card
|
2020-05-12 20:41:34 +03:00
|
|
|
}
|
2020-05-26 18:01:17 +03:00
|
|
|
|
2020-05-12 20:41:34 +03:00
|
|
|
AfterAll {
|
|
|
|
$null = Remove-GitHubProjectCard -Card $card.id -Confirm:$false
|
|
|
|
Remove-Variable -Name card
|
|
|
|
}
|
|
|
|
|
|
|
|
$card.id = (New-GitHubProjectCard -Column $column.id -Note $defaultCard).id
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$result = Get-GitHubProjectCard -Card $card.id
|
2020-05-12 20:41:34 +03:00
|
|
|
|
|
|
|
It 'Card exists' {
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$result | Should Not BeNullOrEmpty
|
2020-05-12 20:41:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
It 'Note is correct' {
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$result.note | Should be $defaultCard
|
2020-05-12 20:41:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Context 'Create project card from issue' {
|
|
|
|
BeforeAll {
|
|
|
|
$card = @{id = 0}
|
2020-05-26 18:01:17 +03:00
|
|
|
|
|
|
|
# Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments
|
|
|
|
$card = $card
|
2020-05-12 20:41:34 +03:00
|
|
|
}
|
2020-05-26 18:01:17 +03:00
|
|
|
|
2020-05-12 20:41:34 +03:00
|
|
|
AfterAll {
|
2020-06-10 17:59:23 +03:00
|
|
|
$null = Remove-GitHubProjectCard -Card $card.id -Force
|
2020-05-12 20:41:34 +03:00
|
|
|
Remove-Variable -Name card
|
|
|
|
}
|
|
|
|
|
|
|
|
$card.id = (New-GitHubProjectCard -Column $column.id -ContentId $issue.id -ContentType 'Issue').id
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$result = Get-GitHubProjectCard -Card $card.id
|
2020-05-12 20:41:34 +03:00
|
|
|
|
|
|
|
It 'Card exists' {
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$result | Should Not BeNullOrEmpty
|
2020-05-12 20:41:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
It 'Content url is for an issue' {
|
Fix multi-result behavior across all versions of PowerShell (fixes CI UT's on all platforms) (#199)
Tests were failing on Mac and Linux, but not Windows ([recent test run](https://dev.azure.com/ms/PowerShellForGitHub/_build/results?buildId=83887&view=logs&j=0da5d1d9-276d-5173-c4c4-9d4d4ed14fdb)). That's because Windows CI was running against PoSh 5.x while Linux and Mac were running on PoSh 7.x.
There's a slight difference in behavior for how those two treat arrays.
The real root cause for this was the behavior of `Invoke-GHRestMethodMultipleResult`. When creating `$finalResult`, it was always blindly adding the result to the existing array:
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L648
`...`
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L670
Oddly enough, this created a difference in behavior between PowerShell versions when making the result an array on the caller side. Now I ensure that I don't add anything to `$finalResult` unless there's actually a value. With that change, we can now be sure that when we grab the result as an array, it'll be appropriately empty or populated (and not populated with a single `$null` entry, thus making `Count` 1, erroneously).
I removed the attempt to force the results to be an array, because this is pointless. PowerShell will always unwrap an array of 0 or 1 in a return result. If you want to ensure that a result is always an array, you have to [wrap the result in an object](https://stackoverflow.com/a/60330501) or you have to do wrap the result in an array on the caller side.
https://github.com/microsoft/PowerShellForGitHub/blob/587e2042621091c79cc06be2aa9cc6ea836561f4/GitHubCore.ps1#L684-L685
I also normalized some naming in all of the tests, so that when we're getting back a singular result (by querying for a specific item) that we use a singular variable name, and a plural variable name otherwise.
With this change, we should now be passing CI on all OS platforms and across PowerShell 4+.
Resolves #198
2020-05-31 01:42:04 +03:00
|
|
|
$result.content_url | Should match 'issues'
|
2020-05-12 20:41:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Describe 'Remove card' {
|
|
|
|
Context 'Remove card' {
|
|
|
|
BeforeAll {
|
|
|
|
$card = New-GitHubProjectCard -Column $column.id -Note $defaultCard
|
2020-05-26 18:01:17 +03:00
|
|
|
|
|
|
|
# Avoid PSScriptAnalyzer PSUseDeclaredVarsMoreThanAssignments
|
|
|
|
$card = $card
|
2020-05-12 20:41:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
$null = Remove-GitHubProjectCard -Card $card.id -Confirm:$false
|
|
|
|
It 'Project card should be removed' {
|
|
|
|
{Get-GitHubProjectCard -Card $card.id} | Should Throw
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Remove-GitHubProject -Project $project.id -Confirm:$false
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
|
|
|
if (Test-Path -Path $script:originalConfigFile -PathType Leaf)
|
|
|
|
{
|
|
|
|
# Restore the user's configuration to its pre-test state
|
|
|
|
Restore-GitHubConfiguration -Path $script:originalConfigFile
|
|
|
|
$script:originalConfigFile = $null
|
|
|
|
}
|
|
|
|
}
|