-
Notifications
You must be signed in to change notification settings - Fork 1.8k
@actions/artifact package updates #408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -190,14 +190,14 @@ describe('Utils', () => { | |
| true | ||
| ) | ||
| expect(utils.isRetryableStatusCode(HttpCodes.GatewayTimeout)).toEqual(true) | ||
| expect(utils.isRetryableStatusCode(429)).toEqual(true) | ||
| expect(utils.isRetryableStatusCode(HttpCodes.TooManyRequests)).toEqual(true) | ||
| expect(utils.isRetryableStatusCode(HttpCodes.OK)).toEqual(false) | ||
| expect(utils.isRetryableStatusCode(HttpCodes.NotFound)).toEqual(false) | ||
| expect(utils.isRetryableStatusCode(HttpCodes.Forbidden)).toEqual(false) | ||
| }) | ||
|
|
||
| it('Test Throttled Status Code', () => { | ||
| expect(utils.isThrottledStatusCode(429)).toEqual(true) | ||
| expect(utils.isThrottledStatusCode(HttpCodes.TooManyRequests)).toEqual(true) | ||
| expect(utils.isThrottledStatusCode(HttpCodes.InternalServerError)).toEqual( | ||
| false | ||
| ) | ||
|
|
@@ -207,6 +207,17 @@ describe('Utils', () => { | |
| ) | ||
| }) | ||
|
|
||
| it('Test Forbidden Status Code', () => { | ||
| expect(utils.isForbiddenStatusCode(HttpCodes.Forbidden)).toEqual(true) | ||
| expect(utils.isForbiddenStatusCode(HttpCodes.InternalServerError)).toEqual( | ||
| false | ||
| ) | ||
| expect(utils.isForbiddenStatusCode(HttpCodes.TooManyRequests)).toEqual( | ||
| false | ||
| ) | ||
| expect(utils.isForbiddenStatusCode(HttpCodes.OK)).toEqual(false) | ||
| }) | ||
|
|
||
| it('Test Creating Artifact Directories', async () => { | ||
| const root = path.join(__dirname, '_temp', 'artifact-download') | ||
| // remove directory before starting | ||
|
|
@@ -216,12 +227,43 @@ describe('Utils', () => { | |
| const directory2 = path.join(directory1, 'folder1') | ||
|
|
||
| // Initially should not exist | ||
| expect(fs.existsSync(directory1)).toEqual(false) | ||
| expect(fs.existsSync(directory2)).toEqual(false) | ||
| await expect(fs.promises.access(directory1)).rejects.not.toBeUndefined() | ||
| await expect(fs.promises.access(directory2)).rejects.not.toBeUndefined() | ||
| const directoryStructure = [directory1, directory2] | ||
| await utils.createDirectoriesForArtifact(directoryStructure) | ||
| // directories should now be created | ||
| expect(fs.existsSync(directory1)).toEqual(true) | ||
| expect(fs.existsSync(directory2)).toEqual(true) | ||
| await expect(fs.promises.access(directory1)).resolves.toEqual(undefined) | ||
| await expect(fs.promises.access(directory2)).resolves.toEqual(undefined) | ||
| }) | ||
|
|
||
| it('Test Creating Empty Files', async () => { | ||
| const root = path.join(__dirname, '_temp', 'empty-files') | ||
| await io.rmRF(root) | ||
|
|
||
| const emptyFile1 = path.join(root, 'emptyFile1') | ||
| const directoryToCreate = path.join(root, 'folder1') | ||
| const emptyFile2 = path.join(directoryToCreate, 'emptyFile2') | ||
|
|
||
| // empty files should only be created after the directory structure is fully setup | ||
| // ensure they are first created by using the createDirectoriesForArtifact method | ||
| const directoryStructure = [root, directoryToCreate] | ||
| await utils.createDirectoriesForArtifact(directoryStructure) | ||
| await expect(fs.promises.access(root)).resolves.toEqual(undefined) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For asynchronously checking if files exist, I used this for guidance
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's wrong with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| await expect(fs.promises.access(directoryToCreate)).resolves.toEqual( | ||
| undefined | ||
| ) | ||
|
|
||
| await expect(fs.promises.access(emptyFile1)).rejects.not.toBeUndefined() | ||
| await expect(fs.promises.access(emptyFile2)).rejects.not.toBeUndefined() | ||
|
|
||
| const emptyFilesToCreate = [emptyFile1, emptyFile2] | ||
| await utils.createEmptyFilesForArtifact(emptyFilesToCreate) | ||
|
|
||
| await expect(fs.promises.access(emptyFile1)).resolves.toEqual(undefined) | ||
| const size1 = (await fs.promises.stat(emptyFile1)).size | ||
| expect(size1).toEqual(0) | ||
| await expect(fs.promises.access(emptyFile2)).resolves.toEqual(undefined) | ||
| const size2 = (await fs.promises.stat(emptyFile2)).size | ||
| expect(size2).toEqual(0) | ||
| }) | ||
| }) | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.