Skip to content
Merged
Changes from 1 commit
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
178 changes: 177 additions & 1 deletion Tests/GitHubRepositories.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,105 @@ $moduleRootPath = Split-Path -Path $PSScriptRoot -Parent

try
{
Describe 'Modifying repositories' {
# Define Script-scoped, readonly, hidden variables.
@{
defaultRepoName = ([Guid]::NewGuid().Guid)
defaultRepoDesc = "This is a description."
defaultRepoHomePage = "https://www.microsoft.com/"
defaultRepoTopic = "microsoft"
modifiedRepoDesc = "This is a modified description."
}.GetEnumerator() | ForEach-Object {
Set-Variable -Force -Scope Script -Option ReadOnly -Visibility Private -Name $_.Key -Value $_.Value
}

Describe 'Getting repositories' {

Context -Name 'For getting a repository' -Fixture {
BeforeAll {
$repo = New-GitHubRepository -RepositoryName $defaultRepoName -Description $defaultRepoDesc -AutoInit
}
AfterAll {
Remove-GitHubRepository -Uri "$($repo.svn_url)" -Verbose
Comment thread
giuseppecampanelli marked this conversation as resolved.
Outdated
}

$newRepo = Get-GitHubRepository -RepositoryName $defaultRepoName
Comment thread
giuseppecampanelli marked this conversation as resolved.
Outdated
It 'Should get repository' {
$newRepo | Should Not BeNullOrEmpty
}

It 'Name is correct' {
$newRepo.name | Should be $defaultRepoName
}

It 'Description is correct' {
$newRepo.description | Should be $defaultRepoDesc
}
}

Context -Name 'For getting a from default/repository' -Fixture {
BeforeAll {
$originalOwnerName = Get-GitHubConfiguration -Name DefaultOwnerName
$originalRepositoryName = Get-GitHubConfiguration -Name DefaultRepositoryName
}
AfterAll {
Set-GitHubConfiguration -DefaultOwnerName $originalOwnerName
Set-GitHubConfiguration -DefaultRepositoryName $originalRepositoryName
}

$repo = Get-GitHubRepository
It 'Should get repository' {
$repo | Should Not BeNullOrEmpty
}

It 'Owner is correct' {
$repo.owner.login | Should be Get-GitHubConfiguration -Name DefaultOwnerName
Comment thread
giuseppecampanelli marked this conversation as resolved.
Outdated
}

It 'Name is correct' {
$repo.name | Should be Get-GitHubConfiguration -Name DefaultRepositoryName
Comment thread
giuseppecampanelli marked this conversation as resolved.
Outdated
}
}
}

Describe 'Creating repositories' {

Context -Name 'For creating a repository' -Fixture {
BeforeAll {
$repo = New-GitHubRepository -RepositoryName $defaultRepoName -Description $defaultRepoDesc -AutoInit
}
AfterAll {
Remove-GitHubRepository -Uri "$($repo.svn_url)" -Verbose
}

It 'Should get repository' {
$repo | Should Not BeNullOrEmpty
}

It 'Name is correct' {
$repo.name | Should be $defaultRepoName
}

It 'Description is correct' {
$repo.Description | Should be $defaultRepoDesc
Comment thread
giuseppecampanelli marked this conversation as resolved.
Outdated
}
}
}

Describe 'Deleting repositories' {

Context -Name 'For deleting a repository' -Fixture {
BeforeAll {
$repo = New-GitHubRepository -RepositoryName $defaultRepoName -Description $defaultRepoDesc -AutoInit
}

$delete = Remove-GitHubRepository -RepositoryName $defaultRepoName -Verbose
Comment thread
giuseppecampanelli marked this conversation as resolved.
Outdated
It 'Should get no content' {
$repo | Should BeNullOrEmpty
Comment thread
giuseppecampanelli marked this conversation as resolved.
Outdated
}
}
}

Describe 'Renaming repositories' {
Comment thread
giuseppecampanelli marked this conversation as resolved.
Outdated

Context -Name 'For renaming a repository' -Fixture {
BeforeEach -Scriptblock {
Expand All @@ -39,6 +137,84 @@ try
}
}
}

Describe 'Updating repositories' {

Context -Name 'For creating a repository' -Fixture {
BeforeAll {
$repo = New-GitHubRepository -RepositoryName $defaultRepoName -Description $defaultRepoDesc -AutoInit
}
AfterAll {
Remove-GitHubRepository -Uri "$($repo.svn_url)" -Verbose
}

It 'Should have the new updated description' {
$updatedRepo = Update-GitHubRepository -RepositoryName $defaultRepoName -Description $modifiedRepoDesc
Comment thread
giuseppecampanelli marked this conversation as resolved.
Outdated
$updatedRepo.description | Should be $modifiedRepoDesc
}

It 'Should have the new updated homepage url' {
$updatedRepo = Update-GitHubRepository -RepositoryName $defaultRepoName -Homepage $defaultRepoHomePage
Comment thread
giuseppecampanelli marked this conversation as resolved.
Outdated
$repo.homepage | Should be $defaultRepoHomePage
}
}
}

Describe 'Get/set repository topic' {

Context -Name 'For creating and getting a repository topic' -Fixture {
BeforeAll {
$repo = New-GitHubRepository -RepositoryName $defaultRepoName -AutoInit
}
AfterAll {
Remove-GitHubRepository -Uri "$($repo.svn_url)" -Verbose
}

It 'Should have the expected topic' {
$topic = Set-GitHubRepositoryTopic -RepositoryName $defaultRepoName -Name ($defaultRepoTopic)
Comment thread
giuseppecampanelli marked this conversation as resolved.
Outdated
Comment thread
giuseppecampanelli marked this conversation as resolved.
Outdated
$updatedRepo.names[0] | Should be $defaultRepoTopics
Comment thread
giuseppecampanelli marked this conversation as resolved.
Outdated
}

It 'Should have no topics' {
$topic = Set-GitHubRepositoryTopic -RepositoryName $defaultRepoName -Clear
Comment thread
giuseppecampanelli marked this conversation as resolved.
Outdated
$updatedRepo.names | Should BeNullOrEmpty
}
}
}

Describe 'Get repository languages' {

Context -Name 'For getting repository languages' -Fixture {
BeforeAll {
$repo = New-GitHubRepositoryLanguage -RepositoryName $defaultRepoName -AutoInit
}
AfterAll {
Remove-GitHubRepository -Uri "$($repo.svn_url)" -Verbose
}

$languages = Get-GitHubRepositoryLanguage -RepositoryName $defaultRepoName
Comment thread
giuseppecampanelli marked this conversation as resolved.
Outdated
It 'Should be empty' {
$languages | Should BeNullOrEmpty
}
}
}

Describe 'Get repository tags' {

Context -Name 'For getting repository tags' -Fixture {
BeforeAll {
$repo = New-GitHubRepositoryLanguage -RepositoryName $defaultRepoName -AutoInit
}
AfterAll {
Remove-GitHubRepository -Uri "$($repo.svn_url)" -Verbose
}

$tags = Get-GitHubRepositoryTag -RepositoryName $defaultRepoName
Comment thread
giuseppecampanelli marked this conversation as resolved.
Outdated
It 'Should be empty' {
$tags | Should BeNullOrEmpty
}
}
}
}
finally
{
Expand Down