Check for 0 sized artifact lists
This commit is contained in:
@@ -373,6 +373,17 @@ describe('upload-artifact', () => {
|
||||
})
|
||||
|
||||
describe('skipArchive option', () => {
|
||||
it('should throw an error if skipArchive is true and files array is empty', async () => {
|
||||
const uploadResp = uploadArtifact(
|
||||
fixtures.inputs.artifactName,
|
||||
[],
|
||||
fixtures.inputs.rootDirectory,
|
||||
{skipArchive: true}
|
||||
)
|
||||
|
||||
await expect(uploadResp).rejects.toThrow(FilesNotFoundError)
|
||||
})
|
||||
|
||||
it('should throw an error if skipArchive is true and multiple files are provided', async () => {
|
||||
const uploadResp = uploadArtifact(
|
||||
fixtures.inputs.artifactName,
|
||||
|
||||
@@ -32,6 +32,10 @@ export async function uploadArtifact(
|
||||
): Promise<UploadArtifactResponse> {
|
||||
let artifactFileName = `${name}.zip`
|
||||
if (options?.skipArchive) {
|
||||
if (files.length === 0) {
|
||||
throw new FilesNotFoundError([])
|
||||
}
|
||||
|
||||
if (files.length > 1) {
|
||||
throw new Error(
|
||||
'skipArchive option is only supported when uploading a single file'
|
||||
|
||||
Reference in New Issue
Block a user