Skip to content

Commit 838239b

Browse files
test: make Artifacts tests use current run artifact names
Agent-Logs-Url: https://github.com/PSModule/GitHub/sessions/2dc56a74-b30d-4c87-92fd-a00e4eba64b5 Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
1 parent 48671e4 commit 838239b

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

tests/Artifacts.Tests.ps1

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,16 @@ Describe 'Artifacts' {
4343
$Owner = $env:GITHUB_REPOSITORY_OWNER
4444
$Repository = $env:GITHUB_REPOSITORY_NAME
4545
$WorkflowRunId = $env:GITHUB_RUN_ID
46-
$ArtifactName = 'module'
46+
$artifacts = Get-GitHubArtifact -Owner $Owner -Repository $Repository -WorkflowRunId $WorkflowRunId -AllVersions
47+
if (-not $artifacts) {
48+
throw 'No artifacts found for this workflow run.'
49+
}
50+
$ArtifactName = ($artifacts | Select-Object -First 1).Name
51+
$ArtifactNameWildcard = if ($ArtifactName.Length -gt 2) {
52+
"$($ArtifactName.Substring(0, 1))*$($ArtifactName.Substring($ArtifactName.Length - 1, 1))"
53+
} else {
54+
"$ArtifactName*"
55+
}
4756
}
4857
AfterAll {
4958
Get-GitHubContext -ListAvailable | Disconnect-GitHubAccount -Silent
@@ -247,7 +256,7 @@ Describe 'Artifacts' {
247256
$params = @{
248257
Owner = $Owner
249258
Repository = $Repository
250-
Name = 'm*ule'
259+
Name = $ArtifactNameWildcard
251260
}
252261
LogGroup 'Artifact' {
253262
$artifact = Get-GitHubArtifact @params

0 commit comments

Comments
 (0)