actions icon indicating copy to clipboard operation
actions copied to clipboard

test(automatic-releases): add tests for "uploadReleaseArtifacts()"

Open pzhlkj6612 opened this issue 2 years ago • 0 comments

This important function should be tested.

I'm not very familiar with Jest. After reading docs, googling and stackoverflowing, I wrote this.
Please feel free to point out problems in my code.

Local test:

$ git clean -xfd && clear && \
>   nvm use && yarn install && clear && \
>   yarn build --scope=automatic-releases && clear && \
>   yarn test automatic-releases \
>     --testNamePattern=uploadReleaseArtifacts \
>     --verbose

...

 PASS   automatic-releases  packages/automatic-releases/__tests__/uploadReleaseArtifacts.test.ts
  uploadReleaseArtifacts handler
    when processing various file lists
      ✓ should upload nothing, if "input.files" is ["assets/*.txt", "assets/*.md"] (24 ms)
      ✓ should upload "LICENSE", if "input.files" is ["assets/*.txt", "assets/LICENSE"] (7 ms)
      ✓ should upload "LICENSE", if "input.files" is ["assets/LICENSE", "assets/*.txt"] (7 ms)
      ✓ should upload "LICENSE" and "test.jar", if "input.files" is ["assets/LICENSE", "assets/*.jar"] (4 ms)
      ✓ should upload "LICENSE" and "test.jar", if "input.files" is ["assets/*"] (2 ms)
    when "client.repos.uploadReleaseAsset()" fails 1 time per file
      ✓ should retry to upload "LICENSE" and "test.jar" with md5 hash appended (224 ms)

----------------------------|---------|----------|---------|---------|
File                        | % Stmts | % Branch | % Funcs | % Lines |
----------------------------|---------|----------|---------|---------|
All files                   |   11.54 |     2.41 |    3.03 |   11.54 |
 automatic-releases/src     |    16.5 |     4.17 |    3.45 |    16.5 |
  ...
  uploadReleaseArtifacts.ts |     100 |      100 |     100 |     100 |
  ...
 ...

...

Test Suites: 6 skipped, 1 passed, 1 of 7 total
Tests:       16 skipped, 6 passed, 22 total
Snapshots:   0 total
Time:        3.198 s, estimated 6 s
Ran all test suites matching /automatic-releases/i with tests matching "uploadReleaseArtifacts".

...

pzhlkj6612 avatar Feb 05 '22 07:02 pzhlkj6612