1
0
Fork 0
mirror of https://github.com/actions/toolkit synced 2025-05-09 16:43:02 +00:00

list for correct backend ids in internal delete

This commit is contained in:
Rob Herley 2024-01-17 17:53:49 -05:00
parent 7fd71a5e13
commit 2f5fb3f92b
No known key found for this signature in database
GPG key ID: D1602042C3543B06
2 changed files with 58 additions and 7 deletions

View file

@ -6,7 +6,7 @@ import {
deleteArtifactPublic
} from '../src/internal/delete/delete-artifact'
import * as config from '../src/internal/shared/config'
import {ArtifactServiceClientJSON} from '../src/generated'
import {ArtifactServiceClientJSON, Timestamp} from '../src/generated'
import * as util from '../src/internal/shared/util'
import {noopLogs} from './common'
@ -145,7 +145,18 @@ describe('delete-artifact', () => {
.mockReturnValue('https://results.local')
})
it('should return a list of artifacts', async () => {
it('should delete an artifact', async () => {
jest
.spyOn(ArtifactServiceClientJSON.prototype, 'ListArtifacts')
.mockResolvedValue({
artifacts: fixtures.artifacts.map(artifact => ({
...fixtures.backendIds,
databaseId: artifact.id.toString(),
name: artifact.name,
size: artifact.size.toString(),
createdAt: Timestamp.fromDate(artifact.createdAt)
}))
})
jest
.spyOn(ArtifactServiceClientJSON.prototype, 'DeleteArtifact')
.mockResolvedValue({
@ -159,6 +170,17 @@ describe('delete-artifact', () => {
})
it('should fail if non-200 response', async () => {
jest
.spyOn(ArtifactServiceClientJSON.prototype, 'ListArtifacts')
.mockResolvedValue({
artifacts: fixtures.artifacts.map(artifact => ({
...fixtures.backendIds,
databaseId: artifact.id.toString(),
name: artifact.name,
size: artifact.size.toString(),
createdAt: Timestamp.fromDate(artifact.createdAt)
}))
})
jest
.spyOn(ArtifactServiceClientJSON.prototype, 'DeleteArtifact')
.mockRejectedValue(new Error('boom'))