Skip to content
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

Introduce unit tests #7

Merged
merged 109 commits into from
Sep 27, 2023
Merged

Introduce unit tests #7

merged 109 commits into from
Sep 27, 2023

Conversation

achumachenko-cloudinary
Copy link
Collaborator

Implemented modifications to allow unit testing and end-to-end testing of the script functionality.

Will allow for better "testability" of the script
The script will be available on PATH if installed globally
Confirmation routines are provided as a module object
Will allow for better "testability"
Using node:util for colorized output
They incapculate "knowledge" about the script output files
Renamed setup function to avoid confusion
@mgriff mgriff self-requested a review August 30, 2023 07:37
Copy link
Collaborator

@mgriff mgriff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added few suggestions/questions in line.

A more general comment on the folder structure, I personally think that it looks cleaner to have all the tests under one folder (rather that with the source files). I realise it can come down to personal choice but there are a few reasons I think we should separate them out:

  • It separates out the core code from the tests files which makes it easier IMO for people to understand the roles of the individual files
  • It helps if you need to run a subset of tests, for example if the different test types are in subfolders of a root test folder, you can use jest test/*/* for all tests, and jest test/unit/* or jest test/integration/* for unit or full e2e tests.
  • This is the same approach that the Cloudinary JS SDK follows so would be more consistent across our code bases

cld-bulk.js Outdated Show resolved Hide resolved
cld-bulk.js Outdated Show resolved Hide resolved
lib/input/cli-helpers.js Show resolved Hide resolved
lib/input/confirmation-routines.js Outdated Show resolved Hide resolved
lib/main-loop.js Show resolved Hide resolved
lib/output/progress.js Show resolved Hide resolved
test/.resources/sample.jpg Outdated Show resolved Hide resolved
@achumachenko-cloudinary
Copy link
Collaborator Author

RE:

A more general comment on the folder structure, I personally think that it looks cleaner to have all the tests under one folder (rather that with the source files). I realise it can come down to personal choice but there are a few reasons I think we should separate them out:

  • It separates out the core code from the tests files which makes it easier IMO for people to understand the roles of the individual files
  • It helps if you need to run a subset of tests, for example if the different test types are in subfolders of a root test folder, you can use jest test/*/* for all tests, and jest test/unit/* or jest test/integration/* for unit or full e2e tests.
  • This is the same approach that the Cloudinary JS SDK follows so would be more consistent across our code bases

I don't think it makes sense to mimic the setup of the SDK (we already use different testing framework jest vs mocha in SDK).

My reasoning has been:

  • This is a small app so it should be easy to make sense of where tests are
  • You can still run specific tests jest lib/input/*

This doesn't seem to be essential aspect of the implementation so I prefer moving faster vs getting things exactly right.
LMK what you think @mgriff

Appreciate all your time and the feedback! 🤘

Cheers!

Copy link
Collaborator

@mgriff mgriff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@achumachenko-cloudinary achumachenko-cloudinary merged commit 83f2b31 into main Sep 27, 2023
@achumachenko-cloudinary achumachenko-cloudinary deleted the introduce_unit_tests branch November 8, 2023 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants