From 8f2cec364060f3d5371570ebb431498d3d5bd9d5 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Fri, 22 Feb 2019 22:02:42 +1300 Subject: [PATCH 1/4] Added support for PartitionId in *-CosmosDBAttachment functions --- CHANGELOG.md | 5 + RELEASENOTES.md | 7 + docs/Get-CosmosDbAttachment.md | 40 +++- docs/New-CosmosDbAttachment.md | 39 +++- docs/Remove-CosmosDbAttachment.md | 30 ++- docs/Set-CosmosDbAttachment.md | 35 +++- src/CosmosDB.psd1 | 114 +++++------ .../attachments/Get-CosmosDbAttachment.ps1 | 23 ++- .../attachments/New-CosmosDbAttachment.ps1 | 15 +- .../attachments/Remove-CosmosDbAttachment.ps1 | 20 +- .../attachments/Set-CosmosDbAttachment.ps1 | 15 +- .../CosmosDB.integration.Tests.ps1 | 94 +++++++++ test/Unit/CosmosDB.attachments.Tests.ps1 | 182 +++++++++++++++++- 13 files changed, 543 insertions(+), 76 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9001b41a..37716014 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## Unreleased + +- Added support for `PartitionId` in `*-CosmosDBAttachment` + functions - fixes [Issue #274](https://github.com/PlagueHO/CosmosDB/issues/274). + ## 3.2.0.320 - Convert module name to be a variable in PSake file to make it more diff --git a/RELEASENOTES.md b/RELEASENOTES.md index c4bab7df..8f2b2441 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,5 +1,12 @@ # Release Notes +## What is New in CosmosDB Unreleased + +February 22, 2018 + +- Added support for `PartitionId` in `*-CosmosDBAttachment` + functions - fixes [Issue #274](https://github.com/PlagueHO/CosmosDB/issues/274). + ## What is New in CosmosDB 3.2.0.320 February 6, 2018 diff --git a/docs/Get-CosmosDbAttachment.md b/docs/Get-CosmosDbAttachment.md index d41ef7e8..a0bd254a 100644 --- a/docs/Get-CosmosDbAttachment.md +++ b/docs/Get-CosmosDbAttachment.md @@ -17,14 +17,14 @@ Return the attachments for a Cosmos DB document. ```powershell Get-CosmosDbAttachment -Context [-Key ] [-KeyType ] [-Database ] - -CollectionId -DocumentId [-Id ] [] + -CollectionId -DocumentId [-Id ] [-PartitionKey ] [] ``` ### Account ```powershell Get-CosmosDbAttachment -Account [-Key ] [-KeyType ] [-Database ] - -CollectionId -DocumentId [-Id ] [] + -CollectionId -DocumentId [-Id ] [-PartitionKey ] [] ``` ## DESCRIPTION @@ -51,6 +51,24 @@ PS C:\> Get-CosmosDbAttachment -Context $cosmosDbContext -CollectionId 'MyNewCol Get an attachment by Id for a document in a collection. +### Example 3 + +```powershell +PS C:\> Get-CosmosDbAttachment -Context $cosmosDbContext -CollectionId 'MyNewCollection' -DocumentId 'ac12345' -PartitionKey 'Id' +``` + +Get all attachments for a document in a collection that contains a +partition key. + +### Example 4 + +```powershell +PS C:\> Get-CosmosDbAttachment -Context $cosmosDbContext -CollectionId 'MyNewCollection' -DocumentId 'ac12345' -Id 'image_1' -PartitionKey 'Id' +``` + +Get an attachment by Id for a document in a collection that contains a +partition key. + ## PARAMETERS ### -Account @@ -183,6 +201,24 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -PartitionKey + +The partition keys for the collection that the attachment is in. +Must be included if and only if the collection is created with +a partitionKey definition. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). diff --git a/docs/New-CosmosDbAttachment.md b/docs/New-CosmosDbAttachment.md index 3fb17b19..b4d35795 100644 --- a/docs/New-CosmosDbAttachment.md +++ b/docs/New-CosmosDbAttachment.md @@ -25,8 +25,8 @@ New-CosmosDbAttachment -Context [-KeyType ] [-Key [-KeyType ] [-Key ] [-Database ] - -CollectionId -DocumentId [-Id ] [-ContentType ] [-Media ] - [-Slug ] [] + -CollectionId -DocumentId [-Id ] [-PartitionKey ] + [-ContentType ] [-Media ] [-Slug ] [] ``` ## DESCRIPTION @@ -43,6 +43,15 @@ PS C:\> New-CosmosDbAttachment -Context $cosmosDbContext -CollectionId 'MyNewCol Create an attachment on a document in a collection. +### Example 2 + +```powershell +PS C:\> New-CosmosDbAttachment -Context $cosmosDbContext -CollectionId 'MyNewCollection' -DocumentId 'ac12345' -Id 'image_1' -ContentType 'image/jpg' -Media 'www.bing.com' -PartitionKey 'id' +``` + +Create an attachment on a document in a collection that is in a collection with +a partition key. + ## PARAMETERS ### -Account @@ -214,6 +223,32 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -PartitionKey + +The partition keys for the collection that the attachment should +be created in. +Must be included if and only if the collection is created with +a partitionKey definition. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Upsert + +Include adds the document to the index. +Exclude omits the document from indexing. +The default for indexing behavior is determined by the automatic +property's value in the indexing policy for the collection. + ### -Slug The name of the attachment. diff --git a/docs/Remove-CosmosDbAttachment.md b/docs/Remove-CosmosDbAttachment.md index 0df3b2fe..340629b8 100644 --- a/docs/Remove-CosmosDbAttachment.md +++ b/docs/Remove-CosmosDbAttachment.md @@ -17,14 +17,14 @@ Delete an attachment from a Cosmos DB document. ```powershell Remove-CosmosDbAttachment -Context [-Database ] [-Key ] [-KeyType ] - -CollectionId -DocumentId -Id [] + -CollectionId -DocumentId -Id [-PartitionKey ] [] ``` ### Account ```powershell Remove-CosmosDbAttachment -Account [-Database ] [-Key ] [-KeyType ] - -CollectionId -DocumentId -Id [] + -CollectionId -DocumentId -Id [-PartitionKey ] [] ``` ## DESCRIPTION @@ -41,6 +41,14 @@ PS C:\> Remove-CosmosDbAttachment -Context $cosmosDbContext -CollectionId 'MyNew Delete an attachment from a document in collection. +### Example 2 + +```powershell +PS C:\> Remove-CosmosDbAttachment -Context $cosmosDbContext -CollectionId 'MyNewCollection' -Id 'ac12345' -Id 'Image_2' -PartitionKey 'Id' +``` + +Delete an attachment from a document in collection that has a parttion key. + ## PARAMETERS ### -Account @@ -173,6 +181,24 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -PartitionKey + +The partition keys for the collection that the attachment is in. +Must be included if and only if the collection is created with +a partitionKey definition. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). diff --git a/docs/Set-CosmosDbAttachment.md b/docs/Set-CosmosDbAttachment.md index a5d32fc2..5f4cd0a6 100644 --- a/docs/Set-CosmosDbAttachment.md +++ b/docs/Set-CosmosDbAttachment.md @@ -17,16 +17,16 @@ Update am attachment for a Cosmos DB document. ```powershell Set-CosmosDbAttachment -Context [-Database ] [-Key ] -CollectionId - -DocumentId -Id [-NewId ] [-ContentType ] [-Media ] [-Slug ] - [] + -DocumentId -Id [-NewId ] [-PartitionKey ] [-ContentType ] + [-Media ] [-Slug ] [] ``` ### Account ```powershell Set-CosmosDbAttachment -Account [-Database ] [-Key ] [-KeyType ] - -CollectionId -DocumentId -Id [-NewId ] [-ContentType ] - [-Media ] [-Slug ] [] + -CollectionId -DocumentId -Id [-NewId ] [-PartitionKey ] + [-ContentType ] [-Media ] [-Slug ] [] ``` ## DESCRIPTION @@ -44,6 +44,15 @@ PS C:\> Set-CosmosDbAttachment -Context $cosmosDbContext -CollectionId 'MyNewCol Rename the Id of an attachment for a document in a collection. +### Example 2 + +```powershell +PS C:\> Set-CosmosDbAttachment -Context $cosmosDbContext -CollectionId 'MyNewCollection' -DocumentId 'ac12345' -Id 'image_1' -NewId 'Image_2' -PartitionKey 'Id' +``` + +Rename the Id of an attachment for a document in a collection that +has a partition key. + ## PARAMETERS ### -Account @@ -227,6 +236,24 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -PartitionKey + +The partition keys for the collection that the attachment is in. +Must be included if and only if the collection is created with +a partitionKey definition. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Slug The name of the attachment. diff --git a/src/CosmosDB.psd1 b/src/CosmosDB.psd1 index 1f2827dd..db7c466e 100644 --- a/src/CosmosDB.psd1 +++ b/src/CosmosDB.psd1 @@ -12,7 +12,7 @@ RootModule = 'CosmosDB.psm1' # Version number of this module. -ModuleVersion = '3.2.0.320' +ModuleVersion = '3.2.1.320' # Supported PSEditions CompatiblePSEditions = 'Core', 'Desktop' @@ -51,7 +51,7 @@ PowerShellVersion = '5.1' # ProcessorArchitecture = '' # Modules that must be imported into the global environment prior to importing this module -RequiredModules = @(@{ModuleName = 'Az.Accounts'; GUID = '17a2feff-488b-47f9-8729-e2cec094624c'; ModuleVersion = '1.0.0'; }, +RequiredModules = @(@{ModuleName = 'Az.Accounts'; GUID = '17a2feff-488b-47f9-8729-e2cec094624c'; ModuleVersion = '1.0.0'; }, @{ModuleName = 'Az.Resources'; GUID = '48bb344d-4c24-441e-8ea0-589947784700'; ModuleVersion = '1.0.0'; }) # Assemblies that must be loaded prior to importing this module @@ -61,63 +61,63 @@ RequiredModules = @(@{ModuleName = 'Az.Accounts'; GUID = '17a2feff-488b-47f9-872 # ScriptsToProcess = @() # Type files (.ps1xml) to be loaded when importing this module -TypesToProcess = 'types\attachments.types.ps1xml', 'types\collections.types.ps1xml', - 'types\databases.types.ps1xml', 'types\documents.types.ps1xml', - 'types\offers.types.ps1xml', 'types\permissions.types.ps1xml', - 'types\storedprocedures.types.ps1xml', - 'types\triggers.types.ps1xml', - 'types\userdefinedfunctions.types.ps1xml', +TypesToProcess = 'types\attachments.types.ps1xml', 'types\collections.types.ps1xml', + 'types\databases.types.ps1xml', 'types\documents.types.ps1xml', + 'types\offers.types.ps1xml', 'types\permissions.types.ps1xml', + 'types\storedprocedures.types.ps1xml', + 'types\triggers.types.ps1xml', + 'types\userdefinedfunctions.types.ps1xml', 'types\users.types.ps1xml' # Format files (.ps1xml) to be loaded when importing this module -FormatsToProcess = 'formats\attachments.formats.ps1xml', - 'formats\collections.formats.ps1xml', - 'formats\databases.formats.ps1xml', - 'formats\documents.formats.ps1xml', 'formats\offers.formats.ps1xml', - 'formats\permissions.formats.ps1xml', - 'formats\storedprocedures.formats.ps1xml', - 'formats\triggers.formats.ps1xml', - 'formats\userdefinedfunctions.formats.ps1xml', +FormatsToProcess = 'formats\attachments.formats.ps1xml', + 'formats\collections.formats.ps1xml', + 'formats\databases.formats.ps1xml', + 'formats\documents.formats.ps1xml', 'formats\offers.formats.ps1xml', + 'formats\permissions.formats.ps1xml', + 'formats\storedprocedures.formats.ps1xml', + 'formats\triggers.formats.ps1xml', + 'formats\userdefinedfunctions.formats.ps1xml', 'formats\users.formats.ps1xml' # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess # NestedModules = @() # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. -FunctionsToExport = 'Get-CosmosDbAccount', 'Get-CosmosDbAccountConnectionString', - 'Get-CosmosDbAccountMasterKey', 'Get-CosmosDbAttachment', - 'Get-CosmosDbAttachmentResourcePath', 'Get-CosmosDbCollection', - 'Get-CosmosDbCollectionResourcePath', 'Get-CosmosDbCollectionSize', - 'Get-CosmosDBDatabase', 'Get-CosmosDBDatabaseResourcePath', - 'Get-CosmosDBDocument', 'Get-CosmosDBDocumentResourcePath', - 'Get-CosmosDBOffer', 'Get-CosmosDBOfferResourcePath', - 'Get-CosmosDbPermission', 'Get-CosmosDbPermissionResourcePath', - 'Get-CosmosDbStoredProcedure', - 'Get-CosmosDbStoredProcedureResourcePath', 'Get-CosmosDbTrigger', - 'Get-CosmosDbTriggerResourcePath', 'Get-CosmosDbUser', - 'Get-CosmosDbUserResourcePath', 'Get-CosmosDbUserDefinedFunction', - 'Get-CosmosDbUserDefinedFunctionResourcePath', - 'Invoke-CosmosDbStoredProcedure', 'New-CosmosDbAccount', - 'New-CosmosDbAccountMasterKey', 'New-CosmosDbAttachment', - 'New-CosmosDbBackoffPolicy', 'New-CosmosDbCollection', - 'New-CosmosDbCollectionIncludedPathIndex', - 'New-CosmosDbCollectionIncludedPath', - 'New-CosmosDbCollectionExcludedPath', - 'New-CosmosDbCollectionIndexingPolicy', - 'New-CosmosDbCollectionUniqueKey', - 'New-CosmosDbCollectionUniqueKeyPolicy', 'New-CosmosDbDatabase', - 'New-CosmosDbDocument', 'New-CosmosDbContext', - 'New-CosmosDbContextToken', 'New-CosmosDbPermission', - 'New-CosmosDbStoredProcedure', 'New-CosmosDbTrigger', - 'New-CosmosDbUser', 'New-CosmosDbUserDefinedFunction', - 'Remove-CosmosDbAccount', 'Remove-CosmosDbAttachment', - 'Remove-CosmosDbCollection', 'Remove-CosmosDbDatabase', - 'Remove-CosmosDbDocument', 'Remove-CosmosDbPermission', - 'Remove-CosmosDbStoredProcedure', 'Remove-CosmosDbTrigger', - 'Remove-CosmosDbUser', 'Remove-CosmosDbUserDefinedFunction', - 'Set-CosmosDbAccount', 'Set-CosmosDbAttachment', - 'Set-CosmosDbCollection', 'Set-CosmosDbDocument', 'Set-CosmosDbOffer', - 'Set-CosmosDbStoredProcedure', 'Set-CosmosDbTrigger', +FunctionsToExport = 'Get-CosmosDbAccount', 'Get-CosmosDbAccountConnectionString', + 'Get-CosmosDbAccountMasterKey', 'Get-CosmosDbAttachment', + 'Get-CosmosDbAttachmentResourcePath', 'Get-CosmosDbCollection', + 'Get-CosmosDbCollectionResourcePath', 'Get-CosmosDbCollectionSize', + 'Get-CosmosDBDatabase', 'Get-CosmosDBDatabaseResourcePath', + 'Get-CosmosDBDocument', 'Get-CosmosDBDocumentResourcePath', + 'Get-CosmosDBOffer', 'Get-CosmosDBOfferResourcePath', + 'Get-CosmosDbPermission', 'Get-CosmosDbPermissionResourcePath', + 'Get-CosmosDbStoredProcedure', + 'Get-CosmosDbStoredProcedureResourcePath', 'Get-CosmosDbTrigger', + 'Get-CosmosDbTriggerResourcePath', 'Get-CosmosDbUser', + 'Get-CosmosDbUserResourcePath', 'Get-CosmosDbUserDefinedFunction', + 'Get-CosmosDbUserDefinedFunctionResourcePath', + 'Invoke-CosmosDbStoredProcedure', 'New-CosmosDbAccount', + 'New-CosmosDbAccountMasterKey', 'New-CosmosDbAttachment', + 'New-CosmosDbBackoffPolicy', 'New-CosmosDbCollection', + 'New-CosmosDbCollectionIncludedPathIndex', + 'New-CosmosDbCollectionIncludedPath', + 'New-CosmosDbCollectionExcludedPath', + 'New-CosmosDbCollectionIndexingPolicy', + 'New-CosmosDbCollectionUniqueKey', + 'New-CosmosDbCollectionUniqueKeyPolicy', 'New-CosmosDbDatabase', + 'New-CosmosDbDocument', 'New-CosmosDbContext', + 'New-CosmosDbContextToken', 'New-CosmosDbPermission', + 'New-CosmosDbStoredProcedure', 'New-CosmosDbTrigger', + 'New-CosmosDbUser', 'New-CosmosDbUserDefinedFunction', + 'Remove-CosmosDbAccount', 'Remove-CosmosDbAttachment', + 'Remove-CosmosDbCollection', 'Remove-CosmosDbDatabase', + 'Remove-CosmosDbDocument', 'Remove-CosmosDbPermission', + 'Remove-CosmosDbStoredProcedure', 'Remove-CosmosDbTrigger', + 'Remove-CosmosDbUser', 'Remove-CosmosDbUserDefinedFunction', + 'Set-CosmosDbAccount', 'Set-CosmosDbAttachment', + 'Set-CosmosDbCollection', 'Set-CosmosDbDocument', 'Set-CosmosDbOffer', + 'Set-CosmosDbStoredProcedure', 'Set-CosmosDbTrigger', 'Set-CosmosDbUser', 'Set-CosmosDbUserDefinedFunction' # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. @@ -157,6 +157,13 @@ PrivateData = @{ # ReleaseNotes of this module ReleaseNotes = ' + ## What is New in CosmosDB Unreleased + + February 22, 2018 + + - Added support for `PartitionId` in `*-CosmosDBAttachment` + functions - fixes [Issue #274](https://github.com/PlagueHO/CosmosDB/issues/274). + ## What is New in CosmosDB 3.2.0.320 February 6, 2018 @@ -295,13 +302,6 @@ PrivateData = @{ - Improved validation on Collection parameter on `*-CosmosDBAttachment*` functions. - Improved validation on Document parameter on `*-CosmosDBAttachment*` functions. - Added tests to validate module manifest is valud - fixes [Issue #236](https://github.com/PlagueHO/CosmosDB/issues/236). - - ## What is New in CosmosDB 2.1.12.137 - - October 30, 2018 - - - Added support for setting Collection uniqueKeyPolicy in - `New-CosmosDbCollection` and `Set-CosmosDbCollection` - fixes [Issue #197](https://github.com/PlagueHO/CosmosDB/issues/197). ' } # End of PSData hashtable diff --git a/src/lib/attachments/Get-CosmosDbAttachment.ps1 b/src/lib/attachments/Get-CosmosDbAttachment.ps1 index a9907af0..26d3aeb6 100644 --- a/src/lib/attachments/Get-CosmosDbAttachment.ps1 +++ b/src/lib/attachments/Get-CosmosDbAttachment.ps1 @@ -44,12 +44,27 @@ function Get-CosmosDbAttachment [Parameter()] [ValidateScript({ Assert-CosmosDbAttachmentIdValid -Id $_ })] [System.String] - $Id + $Id, + + [Parameter()] + [ValidateNotNullOrEmpty()] + [System.String[]] + $PartitionKey ) $null = $PSBoundParameters.Remove('CollectionId') $null = $PSBoundParameters.Remove('DocumentId') + $headers = @{} + + if ($PSBoundParameters.ContainsKey('PartitionKey')) + { + $null = $PSBoundParameters.Remove('PartitionKey') + $headers += @{ + 'x-ms-documentdb-partitionkey' = '["' + ($PartitionKey -join '","') + '"]' + } + } + $resourcePath = ('colls/{0}/docs/{1}/attachments' -f $CollectionId, $DocumentId) if (-not [String]::IsNullOrEmpty($Id)) @@ -59,7 +74,8 @@ function Get-CosmosDbAttachment $result = Invoke-CosmosDbRequest @PSBoundParameters ` -Method 'Get' ` -ResourceType 'attachments' ` - -ResourcePath ('{0}/{1}' -f $resourcePath, $Id) + -ResourcePath ('{0}/{1}' -f $resourcePath, $Id) ` + -Headers $headers $attachment = ConvertFrom-Json -InputObject $result.Content } @@ -68,7 +84,8 @@ function Get-CosmosDbAttachment $result = Invoke-CosmosDbRequest @PSBoundParameters ` -Method 'Get' ` -ResourceType 'attachments' ` - -ResourcePath $resourcePath + -ResourcePath $resourcePath ` + -Headers $headers $body = ConvertFrom-Json -InputObject $result.Content $attachment = $body.Attachments diff --git a/src/lib/attachments/New-CosmosDbAttachment.ps1 b/src/lib/attachments/New-CosmosDbAttachment.ps1 index b9ef419f..14e0db08 100644 --- a/src/lib/attachments/New-CosmosDbAttachment.ps1 +++ b/src/lib/attachments/New-CosmosDbAttachment.ps1 @@ -46,6 +46,11 @@ function New-CosmosDbAttachment [System.String] $Id, + [Parameter()] + [ValidateNotNullOrEmpty()] + [System.String[]] + $PartitionKey, + [Parameter()] [ValidateNotNullOrEmpty()] [System.String] @@ -90,10 +95,18 @@ function New-CosmosDbAttachment if ($PSBoundParameters.ContainsKey('Slug')) { + $null = $PSBoundParameters.Remove('Slug') $headers += @{ 'Slug' = $Slug } - $null = $PSBoundParameters.Remove('Slug') + } + + if ($PSBoundParameters.ContainsKey('PartitionKey')) + { + $null = $PSBoundParameters.Remove('PartitionKey') + $headers += @{ + 'x-ms-documentdb-partitionkey' = '["' + ($PartitionKey -join '","') + '"]' + } } $body = ConvertTo-Json -InputObject $bodyObject diff --git a/src/lib/attachments/Remove-CosmosDbAttachment.ps1 b/src/lib/attachments/Remove-CosmosDbAttachment.ps1 index 30b21401..ee4b2b56 100644 --- a/src/lib/attachments/Remove-CosmosDbAttachment.ps1 +++ b/src/lib/attachments/Remove-CosmosDbAttachment.ps1 @@ -43,7 +43,12 @@ function Remove-CosmosDbAttachment [Parameter(Mandatory = $true)] [ValidateScript({ Assert-CosmosDbAttachmentIdValid -Id $_ })] [System.String] - $Id + $Id, + + [Parameter()] + [ValidateNotNullOrEmpty()] + [System.String[]] + $PartitionKey ) $null = $PSBoundParameters.Remove('CollectionId') @@ -52,8 +57,19 @@ function Remove-CosmosDbAttachment $resourcePath = ('colls/{0}/docs/{1}/attachments/{2}' -f $CollectionId, $DocumentId, $Id) + $headers = @{} + + if ($PSBoundParameters.ContainsKey('PartitionKey')) + { + $null = $PSBoundParameters.Remove('PartitionKey') + $headers += @{ + 'x-ms-documentdb-partitionkey' = '["' + ($PartitionKey -join '","') + '"]' + } + } + $null = Invoke-CosmosDbRequest @PSBoundParameters ` -Method 'Delete' ` -ResourceType 'attachments' ` - -ResourcePath $resourcePath + -ResourcePath $resourcePath ` + -Header $headers } diff --git a/src/lib/attachments/Set-CosmosDbAttachment.ps1 b/src/lib/attachments/Set-CosmosDbAttachment.ps1 index 92b55a0f..5b3e87e8 100644 --- a/src/lib/attachments/Set-CosmosDbAttachment.ps1 +++ b/src/lib/attachments/Set-CosmosDbAttachment.ps1 @@ -51,6 +51,11 @@ function Set-CosmosDbAttachment [System.String] $NewId, + [Parameter()] + [ValidateNotNullOrEmpty()] + [System.String[]] + $PartitionKey, + [Parameter()] [ValidateNotNullOrEmpty()] [System.String] @@ -100,10 +105,18 @@ function Set-CosmosDbAttachment if ($PSBoundParameters.ContainsKey('Slug')) { + $null = $PSBoundParameters.Remove('Slug') $headers += @{ 'Slug' = $Slug } - $null = $PSBoundParameters.Remove('Slug') + } + + if ($PSBoundParameters.ContainsKey('PartitionKey')) + { + $null = $PSBoundParameters.Remove('PartitionKey') + $headers += @{ + 'x-ms-documentdb-partitionkey' = '["' + ($PartitionKey -join '","') + '"]' + } } $body = ConvertTo-Json -InputObject $bodyObject diff --git a/test/Integration/CosmosDB.integration.Tests.ps1 b/test/Integration/CosmosDB.integration.Tests.ps1 index 7b2c1c55..8be9fb91 100644 --- a/test/Integration/CosmosDB.integration.Tests.ps1 +++ b/test/Integration/CosmosDB.integration.Tests.ps1 @@ -68,6 +68,7 @@ $script:testDocumentUTF8UpdateBody = @" $script:testAttachmentId = 'testAttachment' $script:testAttachmentContentType = 'image/jpg' $script:testAttachmentMedia = 'www.bing.com' +$script:testAttachmentMediaUpdated = 'www.contoso.com' $script:testStoredProcedureId = 'testStoredProcedure' $script:testStoredProcedureBody = @' function () { @@ -794,6 +795,26 @@ Describe 'Cosmos DB Module' -Tag 'Integration' { } } + Context 'When updating an attachment from the document in a collection' { + It 'Should not throw an exception' { + $script:result = Set-CosmosDbAttachment ` + -Context $script:testContext ` + -CollectionId $script:testCollection ` + -DocumentId $script:testDocumentId ` + -Id $script:testAttachmentId ` + -ContentType $script:testAttachmentContentType ` + -Media $script:testAttachmentMediaUpdated ` + -Verbose + } + + It 'Should return expected object' { + Test-GenericResult -GenericResult $script:result + $script:result.Id | Should -Be $script:testAttachmentId + $script:result.ContentType | Should -Be $script:testAttachmentContentType + $script:result.Media | Should -Be $script:testAttachmentMediaUpdated + } + } + Context 'When adding a read document permission for a user' { It 'Should not throw an exception' { $script:documentResourcePath = Get-CosmosDbDocumentResourcePath ` @@ -1188,6 +1209,79 @@ Describe 'Cosmos DB Module' -Tag 'Integration' { } } + Context 'When adding an attachment to the document in a collection with a partition key' { + It 'Should not throw an exception' { + $script:result = New-CosmosDbAttachment ` + -Context $script:testContext ` + -CollectionId $script:testCollection ` + -DocumentId $script:testDocumentId ` + -Id $script:testAttachmentId ` + -PartitionKey $script:testDocumentId ` + -ContentType $script:testAttachmentContentType ` + -Media $script:testAttachmentMedia ` + -Verbose + } + + It 'Should return expected object' { + Test-GenericResult -GenericResult $script:result + $script:result.Id | Should -Be $script:testAttachmentId + $script:result.ContentType | Should -Be $script:testAttachmentContentType + $script:result.Media | Should -Be $script:testAttachmentMedia + } + } + + Context 'When getting an attachment from the document in a collection with a partition key' { + It 'Should not throw an exception' { + $script:result = Get-CosmosDbAttachment ` + -Context $script:testContext ` + -CollectionId $script:testCollection ` + -DocumentId $script:testDocumentId ` + -Id $script:testAttachmentId ` + -PartitionKey $script:testDocumentId ` + -Verbose + } + + It 'Should return expected object' { + Test-GenericResult -GenericResult $script:result + $script:result.Id | Should -Be $script:testAttachmentId + $script:result.ContentType | Should -Be $script:testAttachmentContentType + $script:result.Media | Should -Be $script:testAttachmentMedia + } + } + + Context 'When updating an attachment from the document in a collection with a partition key' { + It 'Should not throw an exception' { + $script:result = Set-CosmosDbAttachment ` + -Context $script:testContext ` + -CollectionId $script:testCollection ` + -DocumentId $script:testDocumentId ` + -Id $script:testAttachmentId ` + -PartitionKey $script:testDocumentId ` + -ContentType $script:testAttachmentContentType ` + -Media $script:testAttachmentMediaUpdated ` + -Verbose + } + + It 'Should return expected object' { + Test-GenericResult -GenericResult $script:result + $script:result.Id | Should -Be $script:testAttachmentId + $script:result.ContentType | Should -Be $script:testAttachmentContentType + $script:result.Media | Should -Be $script:testAttachmentMediaUpdated + } + } + + Context 'When removing an attachment from the document in a collection with a partition key' { + It 'Should not throw an exception' { + $script:result = Remove-CosmosDbAttachment ` + -Context $script:testContext ` + -CollectionId $script:testCollection ` + -DocumentId $script:testDocumentId ` + -Id $script:testAttachmentId ` + -PartitionKey $script:testDocumentId ` + -Verbose + } + } + Context 'When removing existing collection with a partition key' { It 'Should not throw an exception' { $script:result = Remove-CosmosDbCollection -Context $script:testContext -Id $script:testCollection -Verbose diff --git a/test/Unit/CosmosDB.attachments.Tests.ps1 b/test/Unit/CosmosDB.attachments.Tests.ps1 index ef69d78b..755afec9 100644 --- a/test/Unit/CosmosDB.attachments.Tests.ps1 +++ b/test/Unit/CosmosDB.attachments.Tests.ps1 @@ -26,6 +26,7 @@ InModuleScope CosmosDB { } $script:testCollection = 'testCollection' $script:testDocument = 'testDocument' + $script:testPartitionKeys = 'testPartitionKey1', 'testPartitionKey2' $script:testAttachment1 = 'testAttachment1' $script:testAttachment2 = 'testAttachment2' $script:testContentType = 'image/jpg' @@ -207,6 +208,42 @@ InModuleScope CosmosDB { } } + Context 'When called with context parameter and no id but with two partition keys' { + $script:result = $null + + Mock ` + -CommandName Invoke-CosmosDbRequest ` + -MockWith { $script:testGetAttachmentResultMulti } + + It 'Should not throw exception' { + $getCosmosDbAttachmentParameters = @{ + Context = $script:testContext + CollectionId = $script:testCollection + DocumentId = $script:testDocument + PartitionKey = $script:testPartitionKeys + } + + { $script:result = Get-CosmosDbAttachment @getCosmosDbAttachmentParameters } | Should -Not -Throw + } + + It 'Should return expected result' { + $script:result.Count | Should -Be 2 + $script:result[0].id | Should -Be $script:testAttachment1 + $script:result[1].id | Should -Be $script:testAttachment2 + } + + It 'Should call expected mocks' { + Assert-MockCalled ` + -CommandName Invoke-CosmosDbRequest ` + -ParameterFilter { + $Method -eq 'Get' -and ` + $ResourceType -eq 'Attachments' -and ` + $Headers.'x-ms-documentdb-partitionkey' -eq '["' + ($script:testPartitionKeys -join '","') + '"]' + } ` + -Exactly -Times 1 + } + } + Context 'When called with context parameter and an id' { $script:result = $null @@ -240,6 +277,42 @@ InModuleScope CosmosDB { -Exactly -Times 1 } } + + Context 'When called with context parameter and an id and with two partition keys' { + $script:result = $null + + Mock ` + -CommandName Invoke-CosmosDbRequest ` + -MockWith { $script:testGetAttachmentResultSingle } + + It 'Should not throw exception' { + $getCosmosDbAttachmentParameters = @{ + Context = $script:testContext + CollectionId = $script:testCollection + DocumentId = $script:testDocument + Id = $script:testAttachment1 + PartitionKey = $script:testPartitionKeys + } + + { $script:result = Get-CosmosDbAttachment @getCosmosDbAttachmentParameters } | Should -Not -Throw + } + + It 'Should return expected result' { + $script:result.id | Should -Be $script:testAttachment1 + } + + It 'Should call expected mocks' { + Assert-MockCalled ` + -CommandName Invoke-CosmosDbRequest ` + -ParameterFilter { + $Method -eq 'Get' -and ` + $ResourceType -eq 'Attachments' -and ` + $ResourcePath -eq ('colls/{0}/docs/{1}/attachments/{2}' -f $script:testCollection, $script:testDocument, $script:testAttachment1) -and ` + $Headers.'x-ms-documentdb-partitionkey' -eq '["' + ($script:testPartitionKeys -join '","') + '"]' + } ` + -Exactly -Times 1 + } + } } Describe 'New-CosmosDbAttachment' -Tag 'Unit' { @@ -281,6 +354,43 @@ InModuleScope CosmosDB { -Exactly -Times 1 } } + + Context 'When called with context parameter and an id and with two partition keys' { + $script:result = $null + + Mock ` + -CommandName Invoke-CosmosDbRequest ` + -MockWith { $script:testGetAttachmentResultSingle } + + It 'Should not throw exception' { + $newCosmosDbAttachmentParameters = @{ + Context = $script:testContext + CollectionId = $script:testCollection + DocumentId = $script:testDocument + Id = $script:testAttachment1 + ContentType = $script:testContentType + Media = $script:testMedia + PartitionKey = $script:testPartitionKeys + } + + { $script:result = New-CosmosDbAttachment @newCosmosDbAttachmentParameters } | Should -Not -Throw + } + + It 'Should return expected result' { + $script:result.id | Should -Be $script:testAttachment1 + } + + It 'Should call expected mocks' { + Assert-MockCalled ` + -CommandName Invoke-CosmosDbRequest ` + -ParameterFilter { + $Method -eq 'Post' -and ` + $ResourceType -eq 'Attachments' -and ` + $Headers.'x-ms-documentdb-partitionkey' -eq '["' + ($script:testPartitionKeys -join '","') + '"]' + } ` + -Exactly -Times 1 + } + } } Describe 'Remove-CosmosDbAttachment' -Tag 'Unit' { @@ -309,10 +419,41 @@ InModuleScope CosmosDB { Assert-MockCalled ` -CommandName Invoke-CosmosDbRequest ` -ParameterFilter { - $Method -eq 'Delete' -and ` + $Method -eq 'Delete' -and ` $ResourceType -eq 'Attachments' -and ` $ResourcePath -eq ('colls/{0}/docs/{1}/attachments/{2}' -f $script:testCollection, $script:testDocument, $script:testAttachment1) - } ` + } ` + -Exactly -Times 1 + } + } + + Context 'When called with context parameter and an id and with two partition keys' { + $script:result = $null + + Mock ` + -CommandName Invoke-CosmosDbRequest + + It 'Should not throw exception' { + $removeCosmosDbAttachmentParameters = @{ + Context = $script:testContext + CollectionId = $script:testCollection + DocumentId = $script:testDocument + Id = $script:testAttachment1 + PartitionKey = $script:testPartitionKeys + } + + { $script:result = Remove-CosmosDbAttachment @removeCosmosDbAttachmentParameters } | Should -Not -Throw + } + + It 'Should call expected mocks' { + Assert-MockCalled ` + -CommandName Invoke-CosmosDbRequest ` + -ParameterFilter { + $Method -eq 'Delete' -and ` + $ResourceType -eq 'Attachments' -and ` + $ResourcePath -eq ('colls/{0}/docs/{1}/attachments/{2}' -f $script:testCollection, $script:testDocument, $script:testAttachment1) -and ` + $Headers.'x-ms-documentdb-partitionkey' -eq '["' + ($script:testPartitionKeys -join '","') + '"]' + } ` -Exactly -Times 1 } } @@ -354,5 +495,42 @@ InModuleScope CosmosDB { -Exactly -Times 1 } } + + Context 'When called with context parameter and an Id and with two partition keys' { + $script:result = $null + + Mock ` + -CommandName Invoke-CosmosDbRequest ` + -MockWith { $script:testGetAttachmentResultSingle } + + It 'Should not throw exception' { + $setCosmosDbAttachmentParameters = @{ + Context = $script:testContext + CollectionId = $script:testCollection + DocumentId = $script:testDocument + Id = $script:testAttachment1 + ContentType = $script:testContentType + Media = $script:testMedia + PartitionKey = $script:testPartitionKeys + } + + { $script:result = Set-CosmosDbAttachment @setCosmosDbAttachmentParameters } | Should -Not -Throw + } + + It 'Should return expected result' { + $script:result.id | Should -Be $script:testAttachment1 + } + + It 'Should call expected mocks' { + Assert-MockCalled ` + -CommandName Invoke-CosmosDbRequest ` + -ParameterFilter { + $Method -eq 'Put' -and ` + $ResourceType -eq 'attachments' -and ` + $Headers.'x-ms-documentdb-partitionkey' -eq '["' + ($script:testPartitionKeys -join '","') + '"]' + } ` + -Exactly -Times 1 + } + } } } From f3537a2cdc1159f4bce5bd513bb89997ed49d210 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Fri, 22 Feb 2019 22:04:19 +1300 Subject: [PATCH 2/4] Correct ChangeLog information --- CHANGELOG.md | 2 +- RELEASENOTES.md | 2 +- src/CosmosDB.psd1 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37716014..2747a7eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- Added support for `PartitionId` in `*-CosmosDBAttachment` +- Added support for `PartitionKey` in `*-CosmosDBAttachment` functions - fixes [Issue #274](https://github.com/PlagueHO/CosmosDB/issues/274). ## 3.2.0.320 diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 8f2b2441..80cc06b9 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -4,7 +4,7 @@ February 22, 2018 -- Added support for `PartitionId` in `*-CosmosDBAttachment` +- Added support for `PartitionKey` in `*-CosmosDBAttachment` functions - fixes [Issue #274](https://github.com/PlagueHO/CosmosDB/issues/274). ## What is New in CosmosDB 3.2.0.320 diff --git a/src/CosmosDB.psd1 b/src/CosmosDB.psd1 index db7c466e..a78650d1 100644 --- a/src/CosmosDB.psd1 +++ b/src/CosmosDB.psd1 @@ -161,7 +161,7 @@ PrivateData = @{ February 22, 2018 - - Added support for `PartitionId` in `*-CosmosDBAttachment` + - Added support for `PartitionKey` in `*-CosmosDBAttachment` functions - fixes [Issue #274](https://github.com/PlagueHO/CosmosDB/issues/274). ## What is New in CosmosDB 3.2.0.320 From 5344bb0427975cadcf1fe044310e27cdb1458e1e Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Fri, 22 Feb 2019 22:22:01 +1300 Subject: [PATCH 3/4] Update Az Modules version in PSDepend --- CHANGELOG.md | 2 ++ RELEASENOTES.md | 2 ++ cosmosdb.depend.psd1 | 4 ++-- src/CosmosDB.psd1 | 2 ++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2747a7eb..041afc33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - Added support for `PartitionKey` in `*-CosmosDBAttachment` functions - fixes [Issue #274](https://github.com/PlagueHO/CosmosDB/issues/274). +- Update `cosmosdb.psdepend.psd1` to install modules `Az.Resources` 1.1.2 and + `Az.Accounts` 1.3.0. ## 3.2.0.320 diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 80cc06b9..15baed7f 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -6,6 +6,8 @@ February 22, 2018 - Added support for `PartitionKey` in `*-CosmosDBAttachment` functions - fixes [Issue #274](https://github.com/PlagueHO/CosmosDB/issues/274). +- Update `cosmosdb.psdepend.psd1` to install modules `Az.Resources` 1.1.2 and + `Az.Accounts` 1.3.0. ## What is New in CosmosDB 3.2.0.320 diff --git a/cosmosdb.depend.psd1 b/cosmosdb.depend.psd1 index 22a404fa..8f8ac227 100644 --- a/cosmosdb.depend.psd1 +++ b/cosmosdb.depend.psd1 @@ -79,7 +79,7 @@ SkipPublisherCheck = $true } Target = 'CurrentUser' - Version = '1.2.1' + Version = '1.3.0' Tags = 'Test','Deploy' } @@ -91,7 +91,7 @@ SkipPublisherCheck = $true } Target = 'CurrentUser' - Version = '1.1.1' + Version = '1.1.2' Tags = 'Test','Deploy' } } diff --git a/src/CosmosDB.psd1 b/src/CosmosDB.psd1 index a78650d1..baa4aec1 100644 --- a/src/CosmosDB.psd1 +++ b/src/CosmosDB.psd1 @@ -163,6 +163,8 @@ PrivateData = @{ - Added support for `PartitionKey` in `*-CosmosDBAttachment` functions - fixes [Issue #274](https://github.com/PlagueHO/CosmosDB/issues/274). + - Update `cosmosdb.psdepend.psd1` to install modules `Az.Resources` 1.1.2 and + `Az.Accounts` 1.3.0. ## What is New in CosmosDB 3.2.0.320 From 9a91438faf8cb2c905f0b44ec0868bc7394d8f36 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Fri, 22 Feb 2019 22:26:11 +1300 Subject: [PATCH 4/4] Suppress verbose output when loading module during automated testing to reduce output --- RELEASENOTES.md | 2 ++ src/CosmosDB.psd1 | 2 ++ test/Integration/CosmosDB.integration.Tests.ps1 | 2 +- test/Unit/CosmosDB.accounts.Tests.ps1 | 2 +- test/Unit/CosmosDB.attachments.Tests.ps1 | 2 +- test/Unit/CosmosDB.collections.Tests.ps1 | 2 +- test/Unit/CosmosDB.databases.Tests.ps1 | 2 +- test/Unit/CosmosDB.documents.Tests.ps1 | 2 +- test/Unit/CosmosDB.offers.Tests.ps1 | 2 +- test/Unit/CosmosDB.permissions.Tests.ps1 | 2 +- test/Unit/CosmosDB.storedprocedures.Tests.ps1 | 2 +- test/Unit/CosmosDB.triggers.Tests.ps1 | 2 +- test/Unit/CosmosDB.userdefinedfunctions.Tests.ps1 | 2 +- test/Unit/CosmosDB.users.Tests.ps1 | 2 +- test/Unit/CosmosDB.utils.Tests.ps1 | 2 +- 15 files changed, 17 insertions(+), 13 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 15baed7f..63f3a982 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -8,6 +8,8 @@ February 22, 2018 functions - fixes [Issue #274](https://github.com/PlagueHO/CosmosDB/issues/274). - Update `cosmosdb.psdepend.psd1` to install modules `Az.Resources` 1.1.2 and `Az.Accounts` 1.3.0. +- Suppress verbose output when loading module during automated + testing to reduce output. ## What is New in CosmosDB 3.2.0.320 diff --git a/src/CosmosDB.psd1 b/src/CosmosDB.psd1 index baa4aec1..b99bad08 100644 --- a/src/CosmosDB.psd1 +++ b/src/CosmosDB.psd1 @@ -165,6 +165,8 @@ PrivateData = @{ functions - fixes [Issue #274](https://github.com/PlagueHO/CosmosDB/issues/274). - Update `cosmosdb.psdepend.psd1` to install modules `Az.Resources` 1.1.2 and `Az.Accounts` 1.3.0. + - Suppress verbose output when loading module during automated + testing to reduce output. ## What is New in CosmosDB 3.2.0.320 diff --git a/test/Integration/CosmosDB.integration.Tests.ps1 b/test/Integration/CosmosDB.integration.Tests.ps1 index 8be9fb91..19525596 100644 --- a/test/Integration/CosmosDB.integration.Tests.ps1 +++ b/test/Integration/CosmosDB.integration.Tests.ps1 @@ -8,7 +8,7 @@ $ModuleManifestName = 'CosmosDB.psd1' $ModuleManifestPath = "$PSScriptRoot\..\..\src\$ModuleManifestName" $TestHelperPath = "$PSScriptRoot\..\TestHelper" -Import-Module -Name $ModuleManifestPath -Force +Import-Module -Name $ModuleManifestPath -Force -Verbose:$false Import-Module -Name $TestHelperPath -Force Get-AzureServicePrincipal diff --git a/test/Unit/CosmosDB.accounts.Tests.ps1 b/test/Unit/CosmosDB.accounts.Tests.ps1 index 5fac3b80..2ff5ddba 100644 --- a/test/Unit/CosmosDB.accounts.Tests.ps1 +++ b/test/Unit/CosmosDB.accounts.Tests.ps1 @@ -6,7 +6,7 @@ param ( $ModuleManifestName = 'CosmosDB.psd1' $ModuleManifestPath = "$PSScriptRoot\..\..\src\$ModuleManifestName" -Import-Module -Name $ModuleManifestPath -Force +Import-Module -Name $ModuleManifestPath -Force -Verbose:$false InModuleScope CosmosDB { $TestHelperPath = "$PSScriptRoot\..\TestHelper" diff --git a/test/Unit/CosmosDB.attachments.Tests.ps1 b/test/Unit/CosmosDB.attachments.Tests.ps1 index 755afec9..b688b2e8 100644 --- a/test/Unit/CosmosDB.attachments.Tests.ps1 +++ b/test/Unit/CosmosDB.attachments.Tests.ps1 @@ -6,7 +6,7 @@ param ( $ModuleManifestName = 'CosmosDB.psd1' $ModuleManifestPath = "$PSScriptRoot\..\..\src\$ModuleManifestName" -Import-Module -Name $ModuleManifestPath -Force +Import-Module -Name $ModuleManifestPath -Force -Verbose:$false InModuleScope CosmosDB { $TestHelperPath = "$PSScriptRoot\..\TestHelper" diff --git a/test/Unit/CosmosDB.collections.Tests.ps1 b/test/Unit/CosmosDB.collections.Tests.ps1 index 3bb9610c..2276914b 100644 --- a/test/Unit/CosmosDB.collections.Tests.ps1 +++ b/test/Unit/CosmosDB.collections.Tests.ps1 @@ -6,7 +6,7 @@ param ( $ModuleManifestName = 'CosmosDB.psd1' $ModuleManifestPath = "$PSScriptRoot\..\..\src\$ModuleManifestName" -Import-Module -Name $ModuleManifestPath -Force +Import-Module -Name $ModuleManifestPath -Force -Verbose:$false InModuleScope CosmosDB { $TestHelperPath = "$PSScriptRoot\..\TestHelper" diff --git a/test/Unit/CosmosDB.databases.Tests.ps1 b/test/Unit/CosmosDB.databases.Tests.ps1 index 911a4852..24b08825 100644 --- a/test/Unit/CosmosDB.databases.Tests.ps1 +++ b/test/Unit/CosmosDB.databases.Tests.ps1 @@ -6,7 +6,7 @@ param ( $ModuleManifestName = 'CosmosDB.psd1' $ModuleManifestPath = "$PSScriptRoot\..\..\src\$ModuleManifestName" -Import-Module -Name $ModuleManifestPath -Force +Import-Module -Name $ModuleManifestPath -Force -Verbose:$false InModuleScope CosmosDB { $TestHelperPath = "$PSScriptRoot\..\TestHelper" diff --git a/test/Unit/CosmosDB.documents.Tests.ps1 b/test/Unit/CosmosDB.documents.Tests.ps1 index 1d135512..21f9e58b 100644 --- a/test/Unit/CosmosDB.documents.Tests.ps1 +++ b/test/Unit/CosmosDB.documents.Tests.ps1 @@ -6,7 +6,7 @@ param ( $ModuleManifestName = 'CosmosDB.psd1' $ModuleManifestPath = "$PSScriptRoot\..\..\src\$ModuleManifestName" -Import-Module -Name $ModuleManifestPath -Force +Import-Module -Name $ModuleManifestPath -Force -Verbose:$false InModuleScope CosmosDB { $TestHelperPath = "$PSScriptRoot\..\TestHelper" diff --git a/test/Unit/CosmosDB.offers.Tests.ps1 b/test/Unit/CosmosDB.offers.Tests.ps1 index 37fd073a..4b2556bb 100644 --- a/test/Unit/CosmosDB.offers.Tests.ps1 +++ b/test/Unit/CosmosDB.offers.Tests.ps1 @@ -6,7 +6,7 @@ param ( $ModuleManifestName = 'CosmosDB.psd1' $ModuleManifestPath = "$PSScriptRoot\..\..\src\$ModuleManifestName" -Import-Module -Name $ModuleManifestPath -Force +Import-Module -Name $ModuleManifestPath -Force -Verbose:$false InModuleScope CosmosDB { $TestHelperPath = "$PSScriptRoot\..\TestHelper" diff --git a/test/Unit/CosmosDB.permissions.Tests.ps1 b/test/Unit/CosmosDB.permissions.Tests.ps1 index 537705d5..07eede84 100644 --- a/test/Unit/CosmosDB.permissions.Tests.ps1 +++ b/test/Unit/CosmosDB.permissions.Tests.ps1 @@ -6,7 +6,7 @@ param ( $ModuleManifestName = 'CosmosDB.psd1' $ModuleManifestPath = "$PSScriptRoot\..\..\src\$ModuleManifestName" -Import-Module -Name $ModuleManifestPath -Force +Import-Module -Name $ModuleManifestPath -Force -Verbose:$false InModuleScope CosmosDB { $TestHelperPath = "$PSScriptRoot\..\TestHelper" diff --git a/test/Unit/CosmosDB.storedprocedures.Tests.ps1 b/test/Unit/CosmosDB.storedprocedures.Tests.ps1 index 1adfe7cf..6d861da2 100644 --- a/test/Unit/CosmosDB.storedprocedures.Tests.ps1 +++ b/test/Unit/CosmosDB.storedprocedures.Tests.ps1 @@ -6,7 +6,7 @@ param ( $ModuleManifestName = 'CosmosDB.psd1' $ModuleManifestPath = "$PSScriptRoot\..\..\src\$ModuleManifestName" -Import-Module -Name $ModuleManifestPath -Force +Import-Module -Name $ModuleManifestPath -Force -Verbose:$false InModuleScope CosmosDB { diff --git a/test/Unit/CosmosDB.triggers.Tests.ps1 b/test/Unit/CosmosDB.triggers.Tests.ps1 index 92e7935a..f1ec1969 100644 --- a/test/Unit/CosmosDB.triggers.Tests.ps1 +++ b/test/Unit/CosmosDB.triggers.Tests.ps1 @@ -6,7 +6,7 @@ param ( $ModuleManifestName = 'CosmosDB.psd1' $ModuleManifestPath = "$PSScriptRoot\..\..\src\$ModuleManifestName" -Import-Module -Name $ModuleManifestPath -Force +Import-Module -Name $ModuleManifestPath -Force -Verbose:$false InModuleScope CosmosDB { $TestHelperPath = "$PSScriptRoot\..\TestHelper" diff --git a/test/Unit/CosmosDB.userdefinedfunctions.Tests.ps1 b/test/Unit/CosmosDB.userdefinedfunctions.Tests.ps1 index 74a7ab7b..e0a972fb 100644 --- a/test/Unit/CosmosDB.userdefinedfunctions.Tests.ps1 +++ b/test/Unit/CosmosDB.userdefinedfunctions.Tests.ps1 @@ -6,7 +6,7 @@ param ( $ModuleManifestName = 'CosmosDB.psd1' $ModuleManifestPath = "$PSScriptRoot\..\..\src\$ModuleManifestName" -Import-Module -Name $ModuleManifestPath -Force +Import-Module -Name $ModuleManifestPath -Force -Verbose:$false InModuleScope CosmosDB { $TestHelperPath = "$PSScriptRoot\..\TestHelper" diff --git a/test/Unit/CosmosDB.users.Tests.ps1 b/test/Unit/CosmosDB.users.Tests.ps1 index bd859770..3e61f5d5 100644 --- a/test/Unit/CosmosDB.users.Tests.ps1 +++ b/test/Unit/CosmosDB.users.Tests.ps1 @@ -6,7 +6,7 @@ param ( $ModuleManifestName = 'CosmosDB.psd1' $ModuleManifestPath = "$PSScriptRoot\..\..\src\$ModuleManifestName" -Import-Module -Name $ModuleManifestPath -Force +Import-Module -Name $ModuleManifestPath -Force -Verbose:$false InModuleScope CosmosDB { $TestHelperPath = "$PSScriptRoot\..\TestHelper" diff --git a/test/Unit/CosmosDB.utils.Tests.ps1 b/test/Unit/CosmosDB.utils.Tests.ps1 index 5421191d..5bd0ace4 100644 --- a/test/Unit/CosmosDB.utils.Tests.ps1 +++ b/test/Unit/CosmosDB.utils.Tests.ps1 @@ -6,7 +6,7 @@ param ( $ModuleManifestName = 'CosmosDB.psd1' $ModuleManifestPath = "$PSScriptRoot\..\..\src\$ModuleManifestName" -Import-Module -Name $ModuleManifestPath -Force +Import-Module -Name $ModuleManifestPath -Force -Verbose:$false InModuleScope CosmosDB { $TestHelperPath = "$PSScriptRoot\..\TestHelper"