-
Notifications
You must be signed in to change notification settings - Fork 46
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
Added a Capacity param on New-CosmosDbAccount - Fixes #439 #440
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
648d2b6
Added Implemented a Capacity param on New-CosmosDbAccount
chrisjantzen 879174a
Updating new Capability param to allow an array of capabilities.
chrisjantzen e8ad340
Fixing documentation on the Capability param
chrisjantzen 2c6bf24
Fixed Capability param test order issues.
chrisjantzen 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ InModuleScope $ProjectName { | |
$script:testConsistencyLevel = 'Strong' | ||
$script:testMaxIntervalInSeconds = 60 | ||
$script:testMaxStalenessPrefix = 900 | ||
$script:testCapability = 'EnableServerless' | ||
$script:testCorsAllowedOrigins = @('https://www.contoso.com', 'https://www.fabrikam.com') | ||
$script:mockGetAzResource = @{ | ||
ResourceId = 'ignore' | ||
|
@@ -76,7 +77,7 @@ InModuleScope $ProjectName { | |
allowedOrigins = ($script:testCorsAllowedOrigins -join ',') | ||
} | ||
) | ||
capabilities = @() | ||
capabilities = @(@{name = $script:testCapability}) | ||
ResourceGroupName = $script:testResourceGroupName | ||
ResourceType = 'Microsoft.DocumentDB/databaseAccounts' | ||
Sku = $null | ||
|
@@ -709,6 +710,67 @@ InModuleScope $ProjectName { | |
-Exactly -Times 1 | ||
} | ||
} | ||
|
||
Context 'When called with a Location specified and the EnableServerless capability' { | ||
$script:result = $null | ||
$testCosmosDBProperties = @{ | ||
databaseAccountOfferType = 'Standard' | ||
locations = @( | ||
@{ | ||
locationName = $script:testLocation | ||
failoverPriority = 0 | ||
} | ||
) | ||
consistencyPolicy = @{ | ||
defaultConsistencyLevel = 'Session' | ||
maxIntervalInSeconds = 5 | ||
maxStalenessPrefix = 100 | ||
} | ||
ipRangeFilter = '' | ||
capabilities = @( | ||
@{ | ||
name = 'EnableServerless' | ||
} | ||
) | ||
} | ||
|
||
$newAzResource_parameterFilter = { | ||
($ResourceType -eq 'Microsoft.DocumentDb/databaseAccounts') -and ` | ||
($ApiVersion -eq '2015-04-08') -and ` | ||
($ResourceName -eq $script:testName) -and ` | ||
($ResourceGroupName -eq $script:testResourceGroupName) -and ` | ||
($Location -eq $script:testLocation) -and ` | ||
($Force -eq $true) -and ` | ||
(ConvertTo-Json -InputObject $Properties) -eq (ConvertTo-Json -InputObject $testCosmosDBProperties) | ||
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. I think the tests are failing here on PS 6/7 because the output of ConvertTo-Json is non-determinate. I've run into this before - essentially the properties will not be output in the same order. So you'd need to actually compare object properties (which is a pain). |
||
} | ||
|
||
Mock ` | ||
-CommandName New-AzResource ` | ||
-MockWith { 'Account' } | ||
|
||
It 'Should not throw exception' { | ||
$newCosmosDbAccountParameters = @{ | ||
Name = $script:testName | ||
ResourceGroupName = $script:testResourceGroupName | ||
Location = $script:testLocation | ||
Capability = $script:testCapability | ||
Verbose = $true | ||
} | ||
|
||
{ $script:result = New-CosmosDbAccount @newCosmosDbAccountParameters } | Should -Not -Throw | ||
} | ||
|
||
It 'Should return expected result' { | ||
$script:result | Should -Be 'Account' | ||
} | ||
|
||
It 'Should call expected mocks' { | ||
Assert-MockCalled ` | ||
-CommandName New-AzResource ` | ||
-ParameterFilter $newAzResource_parameterFilter ` | ||
-Exactly -Times 1 | ||
} | ||
} | ||
} | ||
|
||
Describe 'Set-CosmosDbAccount' -Tag 'Unit' { | ||
|
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 think this line might need to be: