Skip to content

Commit

Permalink
Added fake Get-VSTeamGitRepository call (since pester doesn't recogni…
Browse files Browse the repository at this point in the history
…ze it as something when mocked)

Removed call to dot source common.ps1
Removed debug messages
Cleaned up comments
Bumped Version
Updated Changelog
  • Loading branch information
Bleattler authored and Bleattler committed Aug 18, 2022
1 parent ad000a4 commit 8ce46b7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 25 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Changelog

- Added Update-VSTeamGitRepositoryDefaultBranch to allow for changing the default branch of a repository.
## 7.8.0
- Added Update-VSTeamGitRepositoryDefaultBranch to allow for changing the default branch of a repository
- Fixed bad link in README.md
- Bumped manifest version
- Cleaned up comments/debug messages

## 7.7.0
Merged [Pull Request](https://github.com/MethodsAndPractices/vsteam/pull/470) from [Joshua Davis](https://github.com/a11smiles) the following:
Expand Down
2 changes: 1 addition & 1 deletion Source/VSTeam.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'VSTeam.psm1'

# Version number of this module.
ModuleVersion = '7.7.0'
ModuleVersion = '7.8.0'

# Supported PSEditions
CompatiblePSEditions = @('Core', 'Desktop')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,21 @@ Set-StrictMode -Version Latest
Describe "VSTeamGitRepository" {
BeforeAll {
. "$PSScriptRoot\_testInitialize.ps1" $PSCommandPath
. "$PSScriptRoot\..\..\..\Source\Private\common.ps1"


# Without adding this call, an exception is thrown stating that Get-VSTeamGitRepository is a part of VSTeam but the module could not be loaded. Because we're not testing this function, but it is used in the function we are testing I created it here to facilitate the tests.
function Get-VSTeamGitRepository {
param(
$Name,
$ProjectName
)
$Repo = _callAPI -Method Get -ProjectName $ProjectName `
-Area "git" `
-Resource "repositories" `
-id $Name `
-Version $(_getApiVersion Git)
$Repo
}

Mock Invoke-RestMethod { Open-SampleFile 'Get-VSTeamGitRepository.json' }
Mock Invoke-RestMethod { Open-SampleFile 'Get-VSTeamGitRepository-ProjectNamePeopleTracker-NamePeopleTracker.json' } -ParameterFilter {
$Uri -like "*00000000-0000-0000-0000-000000000000*" -or $URI -like "*Peopletracker*"
Expand All @@ -29,8 +42,6 @@ Describe "VSTeamGitRepository" {

## Assert
Should -Invoke Invoke-RestMethod -ParameterFilter {
Write-Debug "Method : $Method"
Write-Debug "Uri : $Uri"
$Method -eq 'Patch' -and $Uri -eq "https://dev.azure.com/Test/PeopleTracker/_apis/git/repositories/00000000-0000-0000-0000-000000000000?api-version=$(_getApiVersion Git)"
}
}
Expand All @@ -39,24 +50,5 @@ Describe "VSTeamGitRepository" {
{ Update-VSTeamGitRepositoryDefaultBranch -id 00000000-0000-0000-0000-000000000101 -projectname PeopleTracker -DefaultBranch 'develop' } | Should -Throw
}
}

# Context 'Server' {
# BeforeAll {
# ## Arrange
# Mock _getInstance { return 'https://localhost:8080/tfs' }
# }

# It "by name should update Git repo's default branch" {
# ## Act
# Update-VSTeamGitRepositoryDefaultBranch -Name PeopleTracker -projectname PeopleTracker -DefaultBranch 'develop'

# ## Assert
# Should -Invoke Invoke-RestMethod -ParameterFilter {
# Write-Debug "Method : $Method"
# Write-Debug "Uri : $Uri"
# $Method -eq 'Patch' -and $Uri -eq "https://localhost:8080/tfs/PeopleTracker/PeopleTracker/_apis/git/repositories/00000000-0000-0000-0000-000000000000?api-version=$(_getApiVersion Git)"
# }
# }
# }
}
}

0 comments on commit 8ce46b7

Please sign in to comment.