Skip to content

Fix pipeline support and testing for New-GitHubRepositoryFromTemplate #259

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

Merged
merged 1 commit into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions GitHubRepositories.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ filter New-GitHubRepositoryFromTemplate

$elements = Resolve-RepositoryElements -BoundParameters $PSBoundParameters
$OwnerName = $elements.ownerName
$RepositoryName = $elements.repositoryName

$telemetryProperties = @{
RepositoryName = (Get-PiiSafeString -PlainText $RepositoryName)
Expand Down
38 changes: 35 additions & 3 deletions Tests/GitHubRepositories.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -321,16 +321,48 @@ try
}

$repo = New-GitHubRepositoryFromTemplate @newGitHubRepositoryFromTemplateParms
Start-Sleep -Seconds 1 # To work around a delay that GitHub may have with generating the repo
}

It 'Should support pipeline input for the uri parameter' {
It 'Should have the expected type and addititional properties' {
$repo.PSObject.TypeNames[0] | Should -Be 'GitHub.Repository'
$repo.name | Should -Be $repoName
$repo.private | Should -BeFalse
$repo.owner.login | Should -Be $script:ownerName
$repo.description | Should -Be $newRepoDesc
$repo.is_template | Should -BeFalse
$repo.RepositoryId | Should -Be $repo.id
$repo.RepositoryUrl | Should -Be $repo.html_url
}

It 'Should have created a .gitignore file' {
{ Get-GitHubContent -Uri $repo.svn_url -Path '.gitignore' } | Should -Not -Throw
}

It 'Should have created a LICENSE file' {
{ Get-GitHubContent -Uri $repo.svn_url -Path 'LICENSE' } | Should -Not -Throw
}

AfterAll {
if (Get-Variable -Name repo -ErrorAction SilentlyContinue)
{
Remove-GitHubRepository -Uri $repo.svn_url -Confirm:$false
}
}
}

Context 'When creating a public repository from a template (via pipeline input)' {
BeforeAll {
$repoName = ([Guid]::NewGuid().Guid)
$newRepoDesc = 'New Repo Description'
$newGitHubRepositoryFromTemplateParms = @{
TargetOwnerName = $ownerName
TargetRepositoryName = $repoName
Description = $newRepoDesc
}

{ $templateRepo | New-GitHubRepositoryFromTemplate @newGitHubRepositoryFromTemplateParms -WhatIf } |
Should -Not -Throw
$repo = $templateRepo | New-GitHubRepositoryFromTemplate @newGitHubRepositoryFromTemplateParms
Start-Sleep -Seconds 1 # To work around a delay that GitHub may have with generating the repo
}

It 'Should have the expected type and addititional properties' {
Expand Down