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

test(sdl): improve fixture generation to address any further case #92

Merged
merged 1 commit into from
May 14, 2024

Conversation

ygrishajev
Copy link
Contributor

@ygrishajev ygrishajev commented May 14, 2024

This PR introduces enhancements to the testability of the SDL. By leveraging the immutability-helper and dot-object libraries, we have created several functions that generate testing fixtures, such as SDL configurations, groups, and manifests.

Key Benefits

  1. JSON as the Source Format: plain JSON is used for source data, which offers better manageability compared to YAML. This choice simplifies the handling of data structures.

  2. Ease of Creating Fixtures: The new functions make it straightforward to create new fixtures while ensuring that the source data remains unchanged. This improves the reliability and reproducibility of tests.

  3. Enhanced Tooling for JSON Mutation: With enhanced tools to mutate JSON data, these functions provide a robust framework for adjusting test data according to specific test requirements.

  4. Future-proofing: Designed to accommodate nearly any scenario that might arise in future developments, this approach enhances the scalability and adaptability of our testing infrastructure.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.57%. Comparing base (21699d8) to head (0f4c8ca).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #92   +/-   ##
=======================================
  Coverage   71.57%   71.57%           
=======================================
  Files          23       23           
  Lines         795      795           
  Branches      200      200           
=======================================
  Hits          569      569           
  Misses        217      217           
  Partials        9        9           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ygrishajev ygrishajev requested review from Redm4x and baktun14 May 14, 2024 15:48
}).toThrowError(new SdlValidationError(`service "web" credentials missing "${field}"`));
});

it.each(fields)('should throw an error when credentials "%s" is empty', field => {
credentials[field] = "";
const yml = createSdlYml({
"services.web.credentials": { $set: credentials }
Copy link
Contributor

Choose a reason for hiding this comment

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

Pretty cool, I never used immutability-helper per se. Is it strongly typed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. However dot-object is not. I still used it as it's for tests and it simplified code quite a bit. If we feel like it we could add own typing there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Immutability helper is generally used to ui state management :) but it's useful in this case it seems

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea, I used immutablejs a lot in the past

@ygrishajev ygrishajev merged commit 97fe303 into main May 14, 2024
3 checks passed
@ygrishajev ygrishajev deleted the feature/sdl branch May 14, 2024 20:15
Copy link

🎉 This PR is included in version 0.9.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants