Skip to content
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
472 changes: 240 additions & 232 deletions Tests/GitHubAnalytics.tests.ps1

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Tests/GitHubAssignees.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ if (-not $script:accessTokenConfigured)
# Backup the user's configuration before we begin, and ensure we're at a pure state before running
# the tests. We'll restore it at the end.
$configFile = New-TemporaryFile

try
{
Backup-GitHubConfiguration -Path $configFile
Reset-GitHubConfiguration
Set-GitHubConfiguration -DisableTelemetry # We don't want UT's to impact telemetry
Set-GitHubConfiguration -LogRequestBody # Make it easier to debug UT failures

$repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit
$issue = New-GitHubIssue -Uri $repo.svn_url -Title "Test issue"
Expand Down
1 change: 1 addition & 0 deletions Tests/GitHubComments.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ try
Backup-GitHubConfiguration -Path $configFile
Reset-GitHubConfiguration
Set-GitHubConfiguration -DisableTelemetry # We don't want UT's to impact telemetry
Set-GitHubConfiguration -LogRequestBody # Make it easier to debug UT failures

# Define Script-scoped, readonly, hidden variables.

Expand Down
8 changes: 5 additions & 3 deletions Tests/GitHubCore.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,16 @@ if (-not $script:accessTokenConfigured)
Write-Warning -Message ($message -join [Environment]::NewLine)
}

# Backup the user's configuration before we begin, and ensure we're at a pure state before running
# the tests. We'll restore it at the end.
$configFile = New-TemporaryFile

try
{
# Backup the user's configuration before we begin, and ensure we're at a pure state before running
# the tests. We'll restore it at the end.
$configFile = New-TemporaryFile
Backup-GitHubConfiguration -Path $configFile
Reset-GitHubConfiguration
Set-GitHubConfiguration -DisableTelemetry # We don't want UT's to impact telemetry
Set-GitHubConfiguration -LogRequestBody # Make it easier to debug UT failures

Describe 'Testing ConvertTo-SmarterObject behavior' {
InModuleScope PowerShellForGitHub {
Expand Down
2 changes: 2 additions & 0 deletions Tests/GitHubEvents.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ try
{
Backup-GitHubConfiguration -Path $configFile
Reset-GitHubConfiguration
Set-GitHubConfiguration -DisableTelemetry # We don't want UT's to impact telemetry
Set-GitHubConfiguration -LogRequestBody # Make it easier to debug UT failures

if ($accessTokenConfigured)
{
Expand Down
20 changes: 20 additions & 0 deletions Tests/GitHubLabels.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ if (-not $accessTokenConfigured)
# Backup the user's configuration before we begin, and ensure we're at a pure state before running
# the tests. We'll restore it at the end.
$configFile = New-TemporaryFile

try
{
Backup-GitHubConfiguration -Path $configFile
Reset-GitHubConfiguration
Set-GitHubConfiguration -DisableTelemetry # We don't want UT's to impact telemetry
Set-GitHubConfiguration -LogRequestBody # Make it easier to debug UT failures

$defaultLabels = @(
@{
Expand Down Expand Up @@ -300,6 +303,23 @@ try

$null = Remove-GitHubRepository -OwnerName $ownerName -RepositoryName $repositoryName
}

Describe 'Creating a new Issue with labels' {
$repositoryName = [Guid]::NewGuid().Guid
$null = New-GitHubRepository -RepositoryName $repositoryName
Set-GitHubLabel -OwnerName $ownerName -RepositoryName $repositoryName -Label $defaultLabels

$issueName = [Guid]::NewGuid().Guid
$issueLabels = @($defaultLabels[0].name, $defaultLabels[1].name)
$issue = New-GitHubIssue -OwnerName $ownerName -RepositoryName $repositoryName -Title $issueName -Label $issueLabels

It 'Should return the number of labels that were just added' {
$issue.labels.Count | Should be $issueLabels.Count
}

$null = Remove-GitHubRepository -OwnerName $ownerName -RepositoryName $repositoryName
}

Describe 'Removing labels on an issue'{
$repositoryName = [Guid]::NewGuid().Guid
$null = New-GitHubRepository -RepositoryName $repositoryName
Expand Down
2 changes: 2 additions & 0 deletions Tests/GitHubMilestones.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ if (-not $script:accessTokenConfigured)
# Backup the user's configuration before we begin, and ensure we're at a pure state before running
# the tests. We'll restore it at the end.
$configFile = New-TemporaryFile

try
{
Backup-GitHubConfiguration -Path $configFile
Reset-GitHubConfiguration
Set-GitHubConfiguration -DisableTelemetry # We don't want UT's to impact telemetry
Set-GitHubConfiguration -LogRequestBody # Make it easier to debug UT failures

# Define Script-scoped, readonly, hidden variables.

Expand Down
68 changes: 38 additions & 30 deletions Tests/GitHubRepositoryForks.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,46 +70,54 @@ if (-not $script:accessTokenConfigured)
# Backup the user's configuration before we begin, and ensure we're at a pure state before running
# the tests. We'll restore it at the end.
$configFile = New-TemporaryFile
Backup-GitHubConfiguration -Path $configFile
Reset-GitHubConfiguration

Describe 'Creating a new fork for user' {
$originalForks = Get-GitHubRepositoryFork -OwnerName PowerShell -RepositoryName PowerShellForGitHub
try
{
Backup-GitHubConfiguration -Path $configFile
Reset-GitHubConfiguration
Set-GitHubConfiguration -DisableTelemetry # We don't want UT's to impact telemetry
Set-GitHubConfiguration -LogRequestBody # Make it easier to debug UT failures

Context 'When a new fork is created' {
$repo = New-GitHubRepositoryFork -OwnerName PowerShell -RepositoryName PowerShellForGitHub
$newForks = Get-GitHubRepositoryFork -OwnerName PowerShell -RepositoryName PowerShellForGitHub -Sort newest
Describe 'Creating a new fork for user' {
$originalForks = Get-GitHubRepositoryFork -OwnerName PowerShell -RepositoryName PowerShellForGitHub

It 'Should have one more fork than before' {
(@($newForks).Count - @($originalForks).Count) | Should be 1
}
Context 'When a new fork is created' {
$repo = New-GitHubRepositoryFork -OwnerName PowerShell -RepositoryName PowerShellForGitHub
$newForks = Get-GitHubRepositoryFork -OwnerName PowerShell -RepositoryName PowerShellForGitHub -Sort newest

It 'Should be the latest fork in the list' {
$newForks[0].full_name | Should be "$($script:ownerName)/PowerShellForGitHub"
}
It 'Should have one more fork than before' {
(@($newForks).Count - @($originalForks).Count) | Should be 1
}

Remove-GitHubRepository -Uri $repo.svn_url
It 'Should be the latest fork in the list' {
$newForks[0].full_name | Should be "$($script:ownerName)/PowerShellForGitHub"
}

Remove-GitHubRepository -Uri $repo.svn_url
}
}
}

Describe 'Creating a new fork for an org' {
$originalForks = Get-GitHubRepositoryFork -OwnerName PowerShell -RepositoryName PowerShellForGitHub
Describe 'Creating a new fork for an org' {
$originalForks = Get-GitHubRepositoryFork -OwnerName PowerShell -RepositoryName PowerShellForGitHub

Context 'When a new fork is created' {
$repo = New-GitHubRepositoryFork -OwnerName PowerShell -RepositoryName PowerShellForGitHub -OrganizationName $script:organizationName
$newForks = Get-GitHubRepositoryFork -OwnerName PowerShell -RepositoryName PowerShellForGitHub -Sort newest
Context 'When a new fork is created' {
$repo = New-GitHubRepositoryFork -OwnerName PowerShell -RepositoryName PowerShellForGitHub -OrganizationName $script:organizationName
$newForks = Get-GitHubRepositoryFork -OwnerName PowerShell -RepositoryName PowerShellForGitHub -Sort newest

It 'Should have one more fork than before' {
(@($newForks).Count - @($originalForks).Count) | Should be 1
}
It 'Should have one more fork than before' {
(@($newForks).Count - @($originalForks).Count) | Should be 1
}

It 'Should be the latest fork in the list' {
$newForks[0].full_name | Should be "$($script:organizationName)/PowerShellForGitHub"
}
It 'Should be the latest fork in the list' {
$newForks[0].full_name | Should be "$($script:organizationName)/PowerShellForGitHub"
}

Remove-GitHubRepository -Uri $repo.svn_url
Remove-GitHubRepository -Uri $repo.svn_url
}
}
}

# Restore the user's configuration to its pre-test state
Restore-GitHubConfiguration -Path $configFile
finally
{
# Restore the user's configuration to its pre-test state
Restore-GitHubConfiguration -Path $configFile
}
88 changes: 48 additions & 40 deletions Tests/GitHubRepositoryTraffic.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,64 +70,72 @@ if (-not $script:accessTokenConfigured)
# Backup the user's configuration before we begin, and ensure we're at a pure state before running
# the tests. We'll restore it at the end.
$configFile = New-TemporaryFile
Backup-GitHubConfiguration -Path $configFile
Reset-GitHubConfiguration

Describe 'Getting the referrer list' {
$repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit
try
{
Backup-GitHubConfiguration -Path $configFile
Reset-GitHubConfiguration
Set-GitHubConfiguration -DisableTelemetry # We don't want UT's to impact telemetry
Set-GitHubConfiguration -LogRequestBody # Make it easier to debug UT failures

Context 'When initially created, there are no referrers' {
$referrerList = Get-GitHubReferrerTraffic -Uri $repo.svn_url
Describe 'Getting the referrer list' {
$repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit

It 'Should return expected number of referrers' {
@($referrerList).Count | Should be 0
}
Context 'When initially created, there are no referrers' {
$referrerList = Get-GitHubReferrerTraffic -Uri $repo.svn_url

Remove-GitHubRepository -Uri $repo.svn_url
It 'Should return expected number of referrers' {
@($referrerList).Count | Should be 0
}

Remove-GitHubRepository -Uri $repo.svn_url
}
}
}

Describe 'Getting the popular content over the last 14 days' {
$repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit
Describe 'Getting the popular content over the last 14 days' {
$repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit

Context 'When initially created, there are is no popular content' {
$pathList = Get-GitHubPathTraffic -Uri $repo.svn_url
Context 'When initially created, there are is no popular content' {
$pathList = Get-GitHubPathTraffic -Uri $repo.svn_url

It 'Should return expected number of popular content' {
@($pathList).Count | Should be 0
}
It 'Should return expected number of popular content' {
@($pathList).Count | Should be 0
}

Remove-GitHubRepository -Uri $repo.svn_url
Remove-GitHubRepository -Uri $repo.svn_url
}
}
}

Describe 'Getting the views over the last 14 days' {
$repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit
Describe 'Getting the views over the last 14 days' {
$repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit

Context 'When initially created, there are no views' {
$viewList = Get-GitHubViewTraffic -Uri $repo.svn_url
Context 'When initially created, there are no views' {
$viewList = Get-GitHubViewTraffic -Uri $repo.svn_url

It 'Should return 0 in the count property' {
$viewList.Count | Should be 0
}
It 'Should return 0 in the count property' {
$viewList.Count | Should be 0
}

Remove-GitHubRepository -Uri $repo.svn_url
Remove-GitHubRepository -Uri $repo.svn_url
}
}
}

Describe 'Getting the clones over the last 14 days' {
$repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit
Describe 'Getting the clones over the last 14 days' {
$repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit

Context 'When initially created, there is 0 clones' {
$cloneList = Get-GitHubCloneTraffic -Uri $repo.svn_url
Context 'When initially created, there is 0 clones' {
$cloneList = Get-GitHubCloneTraffic -Uri $repo.svn_url

It 'Should return expected number of clones' {
$cloneList.Count | Should be 0
}
It 'Should return expected number of clones' {
$cloneList.Count | Should be 0
}

Remove-GitHubRepository -Uri $repo.svn_url
Remove-GitHubRepository -Uri $repo.svn_url
}
}
}

# Restore the user's configuration to its pre-test state
Restore-GitHubConfiguration -Path $configFile
finally
{
# Restore the user's configuration to its pre-test state
Restore-GitHubConfiguration -Path $configFile
}