-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial release #1
Open
CameronSWilliamson
wants to merge
29
commits into
main
Choose a base branch
from
feature/basic-functions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 15 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
f8768f1
Adding dynamic fetching for .NET library dependencies.
CameronSWilliamson cc5cd34
Adding New-YTSession function that creates a session object.
CameronSWilliamson 508ae23
Adding automated setup for YouTrack
CameronSWilliamson 182bf56
Moving automation to python to make it easier on appveyor
CameronSWilliamson 7095cbb
Providing zipped YouTrack instance for testing
CameronSWilliamson ae989f8
Ending Youtrack process on build servers
CameronSWilliamson 90436aa
Adding support for Unix operating systems
CameronSWilliamson 1ffe7c3
Removing all dll dependencies
CameronSWilliamson 6318490
Updating init to use ytconfig.zip and download youtrack from the website
CameronSWilliamson ef6f213
Adding Invoke-YTRestMethod function
CameronSWilliamson a7d7e6d
Adding Get-YTIssue function
CameronSWilliamson b3e3aa1
Adding get project and new project functions
CameronSWilliamson 0884e6c
Adding New-YTIssue function and unittests
CameronSWilliamson 46dcf80
Fixing failing tests
CameronSWilliamson 1866c5f
Ready for first release
CameronSWilliamson 4a15b62
Adding Remove-YTProject function
CameronSWilliamson aea8cb2
Removing all projects before each test suite
CameronSWilliamson 97110c4
Adding test that makes a real request
CameronSWilliamson ef243a3
Adding support for error descriptions when invoking youtrack rest met…
CameronSWilliamson c5ad7a8
Adding Remove-AllProjects helper function and updating documentation …
CameronSWilliamson 5b5a418
Adding function to get IDs for custom fields and to get the state of …
CameronSWilliamson 4cd3f22
Adding support for getting an issue's custom fields.
CameronSWilliamson 0f1c7c3
Check in YouTrack config as loose files instead of a zip.
KhoiKy 4532698
Rename test helper function to Clear-Project.
KhoiKy b43813d
Use EscapeDataString instead of EscapeUriString.
KhoiKy b25e25f
Parameter name should be singular.
KhoiKy f7ceb28
Update module's help.txt
KhoiKy b69a854
Update tests so that they don't mock invoking of rest methods.
KhoiKy 3f058e7
Improve documentation on functions.
KhoiKy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
Set-StrictMode -Version 'Latest' | ||
|
||
BeforeAll { | ||
Set-StrictMode -Version 'Latest' | ||
|
||
& (Join-Path -Path $PSScriptRoot -ChildPath 'Initialize-Test.ps1' -Resolve) | ||
|
||
function WhenGettingIssue | ||
{ | ||
[CmdletBinding()] | ||
param( | ||
[Parameter(Mandatory)] | ||
[String] $IssueId, | ||
[String] $AdditionalFields | ||
) | ||
|
||
$script:result = Get-YTIssue -Session $session @PSBoundParameters | ||
} | ||
|
||
function ThenIssueHasValue | ||
{ | ||
[CmdletBinding()] | ||
param( | ||
[String] $Field, | ||
[String] $Value | ||
) | ||
|
||
$script:result.$Field | Should -Be $Value | ||
} | ||
|
||
function ThenIssueHasField | ||
{ | ||
[CmdletBinding()] | ||
param( | ||
[String] $Field | ||
) | ||
|
||
$script:result.$Field | Should -Not -BeNullOrEmpty | ||
} | ||
} | ||
|
||
Describe 'Get-YTIssue' { | ||
BeforeEach { | ||
$script:session = New-YTSession -Url $apiUrl -ApiToken $apiToken | ||
} | ||
|
||
It 'should return an issue using the ''jira id''' { | ||
WhenGettingIssue -IssueId '3-4' | ||
ThenIssueHasValue -Field 'idReadable' -Value 'DEMO-5' | ||
ThenIssueHasValue -Field 'id' -Value '3-4' | ||
ThenIssueHasValue -Field 'summary' -Value 'First steps for project administrators' | ||
} | ||
|
||
It 'should return an issue using the ''issue key''' { | ||
WhenGettingIssue -IssueId 'DEMO-1' | ||
ThenIssueHasValue -Field 'id' -Value '3-0' | ||
ThenIssueHasValue -Field 'idReadable' -Value 'DEMO-1' | ||
ThenIssueHasValue -Field 'summary' -Value 'Launch YouTrack' | ||
} | ||
|
||
It 'should support additional fields' { | ||
$additionalFields = 'comments(id,author(name),text,created,updated)' | ||
WhenGettingIssue -IssueId 'DEMO-1' -AdditionalFields $additionalFields | ||
ThenIssueHasField -Field 'comments' | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
Set-StrictMode -Version 'Latest' | ||
|
||
BeforeAll { | ||
Set-StrictMode -Version 'Latest' | ||
|
||
& (Join-Path -Path $PSScriptRoot -ChildPath 'Initialize-Test.ps1' -Resolve) | ||
|
||
function GivenProject | ||
{ | ||
[CmdletBinding()] | ||
param( | ||
[String] $ShortName = 'GYTP1', | ||
[String] $Name = 'Get-YTProject Test Project', | ||
[String] $Leader = 'admin' | ||
) | ||
|
||
New-YTProject -Session $script:session -ShortName $ShortName -Name $Name -Leader $Leader -Description 'This is a test project.' | ||
} | ||
|
||
function WhenGettingProject | ||
{ | ||
[CmdletBinding()] | ||
param( | ||
[String] $ProjectShortName, | ||
[String] $AdditionalFields | ||
) | ||
|
||
$script:result = Get-YTProject -Session $script:session @PSBoundParameters | ||
} | ||
|
||
function ThenProjectHasField | ||
{ | ||
[CmdletBinding()] | ||
param( | ||
[String] $Field | ||
) | ||
|
||
$script:result.$Field | Should -Not -BeNullOrEmpty | ||
} | ||
|
||
function ThenProjectsReturned | ||
{ | ||
[CmdletBinding()] | ||
param( | ||
[Int] $GreaterThanEqual = 1 | ||
|
||
) | ||
$script:result | Should -Not -BeNullOrEmpty | ||
if (Get-Member -Name Length -InputObject $script:result -ErrorAction SilentlyContinue) | ||
{ | ||
$script:result.Length | Should -BeGreaterOrEqual $GreaterThanEqual | ||
} | ||
$idCount = | ||
$script:result | | ||
ForEach-Object { $_.id } | | ||
Select-Object -Unique | | ||
Measure-Object | | ||
Select-Object -ExpandProperty Count | ||
$script:result | Should -HaveCount $idCount | ||
} | ||
|
||
function ThenProjectWithShortName | ||
{ | ||
[CmdletBinding()] | ||
param( | ||
[String] $ShortName | ||
) | ||
|
||
$script:result | | ||
ForEach-Object { $_.shortName} | | ||
Where-Object { $_ -eq $ShortName } | | ||
Should -Not -BeNullOrEmpty | ||
} | ||
} | ||
|
||
Describe 'Get-YTIssue' { | ||
BeforeEach { | ||
$script:session = New-YTSession -Url $apiUrl -ApiToken $apiToken | ||
} | ||
|
||
It 'returns one project' { | ||
GivenProject -ShortName 'GYTP1' -Name 'Get-YTProject Test Project' -Leader 'admin' | ||
WhenGettingProject -ProjectShortName 'DEMO' | ||
ThenProjectsReturned -GreaterThanEqual 1 | ||
ThenProjectWithShortName -ShortName 'DEMO' | ||
} | ||
|
||
It 'return all projects' { | ||
WhenGettingProject | ||
ThenProjectsReturned -GreaterThanEqual 2 | ||
ThenProjectWithShortName -ShortName 'DEMO' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assert both projects that get returned. |
||
} | ||
|
||
It 'should support additional fields' { | ||
WhenGettingProject -AdditionalFields 'description' | ||
ThenProjectsReturned -GreaterThanEqual 2 | ||
$script:result | Where-Object {$_.shortName -eq 'GYTP1'} | ForEach-Object { $_.description } | Should -Not -BeNullOrEmpty | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
Set-StrictMode -Version 'Latest' | ||
|
||
BeforeAll { | ||
Set-StrictMode -Version 'Latest' | ||
|
||
& (Join-Path -Path $PSScriptRoot -ChildPath 'Initialize-Test.ps1' -Resolve) | ||
|
||
function MockIrm | ||
{ | ||
param( | ||
[Object] $MockWith, | ||
[scriptblock] $ParameterFilter | ||
) | ||
|
||
$splat = @{} | ||
if ($ParameterFilter) | ||
{ | ||
$splat['ParameterFilter'] = $ParameterFilter | ||
} | ||
|
||
if ($MockWith) | ||
{ | ||
$splat['MockWith'] = $MockWith | ||
} | ||
|
||
|
||
Mock -CommandName 'Invoke-RestMethod' -ModuleName 'YouTrackAutomation' @splat | ||
} | ||
|
||
function ThenRestMethodInvoked | ||
{ | ||
param( | ||
[int] $Times = 1, | ||
[scriptblock] $ParameterFilter | ||
) | ||
|
||
$splat = @{} | ||
if ($ParameterFilter) | ||
{ | ||
$splat['ParameterFilter'] = $ParameterFilter | ||
} | ||
|
||
Should -Invoke 'Invoke-RestMethod' -ModuleName 'YouTrackAutomation' -Times $Times @splat | ||
} | ||
|
||
function ThenRestMethodNotInvoked | ||
{ | ||
Should -Not -Invoke 'Invoke-RestMethod' -ModuleName 'YouTrackAutomation' | ||
} | ||
} | ||
|
||
Describe 'Invoke-YTRestMethod' { | ||
splatteredbits marked this conversation as resolved.
Show resolved
Hide resolved
|
||
BeforeEach { | ||
$script:session = New-YTSession -Url $apiUrl -ApiToken $apiToken | ||
} | ||
|
||
It 'should always make GET requests' { | ||
splatteredbits marked this conversation as resolved.
Show resolved
Hide resolved
|
||
MockIrm -MockWith { 'get-request' } | ||
$res = Invoke-YTRestMethod -Session $script:session -Name 'wikis' -Method Get | ||
$res | Should -Be 'get-request' | ||
$res = Invoke-YTRestMethod -Session $script:session -Name 'wikis' -Method Get -WhatIf | ||
$res | Should -Be 'get-request' | ||
ThenRestMethodInvoked -Times 2 | ||
|
||
} | ||
|
||
It 'should not make PUT requests with WhatIf' { | ||
MockIrm -MockWith { 'put-request' } | ||
$res = Invoke-YTRestMethod -Session $script:session -Name 'wikis' -Method Put | ||
$res | Should -Be 'put-request' | ||
$res = Invoke-YTRestMethod -Session $script:session -Name 'wikis' -Method Put -WhatIf | ||
$res | Should -BeNullOrEmpty | ||
ThenRestMethodInvoked -Times 1 | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would combine the two
ThenProject*
functions into a singleThenReturns
function:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use
GreaterThanEqual
. Use an exact count. If you use greater than or equal to, if the API returns more than expected, tests will still pass.