refactor: resolve download path correctly in artifact download tests (mainly for windows unit tests)

This commit is contained in:
GrantBirki 2025-08-05 11:26:03 -07:00
parent e262cbee4a
commit b19ff43027
No known key found for this signature in database
GPG Key ID: 65497A530F6F9405

View File

@ -1,4 +1,5 @@
import * as core from '@actions/core'
import * as path from 'path'
import artifact, {ArtifactNotFoundError} from '@actions/artifact'
import {run} from '../src/download-artifact'
import {Inputs} from '../src/constants'
@ -380,11 +381,12 @@ describe('download', () => {
digest: 'def456'
}
const testPath = '/test/path'
mockInputs({
[Inputs.Name]: '',
[Inputs.Pattern]: '',
[Inputs.ArtifactIds]: '456',
[Inputs.Path]: '/test/path'
[Inputs.Path]: testPath
})
jest.spyOn(artifact, 'listArtifacts').mockImplementation(() =>
@ -399,7 +401,7 @@ describe('download', () => {
expect(artifact.downloadArtifact).toHaveBeenCalledWith(
456,
expect.objectContaining({
path: '/test/path', // Should be the resolved path directly, not /test/path/test-artifact
path: path.resolve(testPath), // Should be the resolved path directly, not nested
expectedHash: mockArtifact.digest
})
)