Skip to content

Commit 0d03b90

Browse files
committed
Added VersionId alias and integration tests for both alias and parameter
1 parent b3c8bf3 commit 0d03b90

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

modules/AWSPowerShell/Cmdlets/S3/Advanced/Read-S3Object-Cmdlet.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ public class ReadS3ObjectCmdlet : AmazonS3ClientCmdlet, IExecutor
135135
/// <summary>
136136
/// If specified, the specific version of the S3 object is returned.
137137
/// </summary>
138+
[Alias("VersionId")]
138139
[Parameter(Position = 3, ParameterSetName = ParamSet_ToLocalFile, ValueFromPipelineByPropertyName = true)]
139140
public System.String Version { get; set; }
140141
#endregion

tests/S3/S3.Tests.ps1

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ Describe -Tag "Smoke" "S3" {
7373
BeforeAll {
7474
$script:bucketName = "pstest-" + [DateTime]::Now.ToFileTime()
7575
New-S3Bucket -BucketName $script:bucketName
76-
76+
77+
$key = "versionTest"
7778
$void = New-Item -Path temp\bar -Type directory -Force
7879
$void = New-Item -Path temp\bar\baz -Type directory -Force
7980

@@ -85,6 +86,13 @@ Describe -Tag "Smoke" "S3" {
8586
Write-S3Object -BucketName $script:bucketName -KeyPrefix bar2\ -Folder .\temp\bar -Recurse
8687
Write-S3Object -BucketName $script:bucketName -Key bar2\foo.txt -Content "foo"
8788
Write-S3Object -BucketName $script:bucketName -Key basic.txt -File "temp\basic.txt"
89+
90+
Write-S3BucketVersioning -BucketName $script:bucketName -VersioningConfig_Status Enabled
91+
92+
Write-S3Object -BucketName $script:bucketName -Key $key -Content "Version 1"
93+
Write-S3Object -BucketName $script:bucketName -Key $key -Content "Version 2"
94+
95+
$s3ObjectVersions = Get-S3Version -BucketName $script:bucketName -Prefix $key
8896
}
8997

9098
AfterAll {
@@ -129,6 +137,18 @@ Describe -Tag "Smoke" "S3" {
129137
Read-S3Object -BucketName $script:bucketName -Key "basic.txt" -File "temp\basic2.txt"
130138
(Get-Content "temp\basic2.txt").Length | Should -BeGreaterThan 0
131139
}
140+
141+
It "Can retrieve a specific version using the VersionId alias" {
142+
$versionId = $s3ObjectVersions.Versions[0].VersionId
143+
Read-S3Object -BucketName $script:bucketName -Key $key -VersionId $versionId -File "temp\version-test.txt"
144+
(Get-Content "temp\version-test.txt") | Should -Be "Version 2"
145+
}
146+
147+
It "Can retrieve a specific version using the Version parameter" {
148+
$versionId = $s3ObjectVersions.Versions[1].VersionId
149+
Read-S3Object -BucketName $script:bucketName -Key $key -Version $versionId -File "temp\version-test.txt"
150+
(Get-Content "temp\version-test.txt") | Should -Be "Version 1"
151+
}
132152
}
133153

134154
Context "Copying" {

0 commit comments

Comments
 (0)