aws / aws-toolkit-azure-devops

AWS Toolkit for Azure DevOps
Other
235 stars 100 forks source link

Fix beanstalkutils-test filename issue and improve log readability #541

Closed rbbarad closed 5 months ago

rbbarad commented 5 months ago

Description

Fixes a few issues with beanstalkutils-test.ts

Unhandled ENOENT error

This change fixes ENOENT errors similar to the one found in #538

Error: ENOENT: no such file or directory, open 'C:\Users\rbbarad\Desktop\azdo\public-repo\aws-toolkit-azure-devops\tests\taskTests\common\C:\Users\rbbarad\Desktop\azdo\public-repo\aws-toolkit-azure-devops\tests\taskTests\common\beanstalkutils-test.ts'
Emitted 'error' event on ReadStream instance at:
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'C:\\Users\\rbbarad\\Desktop\\azdo\\public-repo\\aws-toolkit-azure-devops\\tests\\taskTests\\common\\C:\\Users\\rbbarad\\Desktop\\azdo\\public-repo\\aws-toolkit-azure-devops\\tests\\taskTests\\common\\beanstalkutils-test.ts'
}

In this case, the issue was due to malformed paths (e.g. path.join(__dirname, __filename) instead of just __filename).

Since this readStream error was previously unhandled and the test assertions still matched what was expected, our unit tests were still technically passing. However, it is the buildup of these types of errors across the test suite that contributes to the overall flakiness of our Unit tests (see #538). This change cleans that up for the beanstalk tests.

This change also adds the proper error handling for ReadableStreams.

Log Readability

  1. Our intentional 'expect this test to throw' type of tests still output the error to the logs. It isn't clear at first glance that these errors are expected since they look very similar to real errors that can come up. This adds description to the log output so that it is easier for future maintainers to discern

  2. Removes a duplicated error message output

Testing

Checklist

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.