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