callawaycloud/Salesforce-Environment-Vars

Ability to set mocked version of a variable value in unit tests

Closed this issue · 16 comments

Hi. First of all, @ChuckJonas , thank you for implementing and sharing this project!

I want to ask you about addition that would allow us to unit tests based on the mocked version of variables value. It is critical for our implementations, and I want to leverage an official packaged version of the project. If I create PR with the implemented feature, how much time do you think it will take to complete a package for you?

Hey Ruslan,

Would love to see this feature added and would absolutely welcome a PR. It's something I had planned on at the start but never had time.

Should be able to release it pretty quick once the PR is reviewed and approved.

Thanks!

Long time no chat, @ChuckJonas, thank you for your reply!
We will work on PR to implement mocking functionality starting next week. Hopefully, it won't take longer than 1-2 days. Stay tuned.

@ChuckJonas, would you be able to review #35 and provide your feedback, please? Let us know what do you think should be adjusted.

Hello, @ChuckJonas. Would you be able to review #35 , please?

I probably won't be able to get to it today sorry. Maybe tomorrow.

It works, thank you @ChuckJonas !

Hello, @ChuckJonas . Just wondering, have you had a chance to look into the #35 pull request?

Sorry, I've been very busy. This is on my list for today. I've merged the PR but still have to release the new package

ugh, just went to "promote" and get an error:

ERROR running force:package:version:promote:  Code coverage has not been run for this version.  Code coverage must be run during version creation and meet the minimum coverage requirement to promote the version.

I guess this is a new requirements? I would think this package would have >75% coverage tho.

I don't really do much SF dev anymore so this is new to me

@ChuckJonas We will review coverage and get back to you soon. Or are you going to look into this?

I doesn't seem like the tests are even running. I just tried to create the package version with --codecoverage option and it still doesn't seem to be running the tests.

IDK if maybe my sfdx cli tool is just too out of date

Hello, @ChuckJonas . How is it going, have you managed to create a version? ;)

I haven't tried since I ran into that issue. If you have any suggestions on how to resolve it, I can give it a go

Hello, @ChuckJonas! I have investigated the issue, and it looks like we have miscommunication. I am using the Unlocked version of your package in production org. We haven't started to use managed package "extension" for secrets. Mainly, I asked to build an unlocked version of the env-vars package and update the sfdx-package.json with a correct Id.

And regarding the secrets managed package, I believe you are right - you can't promote a package version as a released version if it doesn't have enough code coverage. That that is exactly the case for classes the project has (see screenshot):
Screenshot 2021-12-13 at 12 24 40

I have several suggestions/questions for you:

  1. Would you be able to create a new Unlocked version of the env-vars package and provide an Id of the version?
  2. If it is not interesting for you anymore (based on your previous messages), I want to offer to become a second maintainer of the project. I would review requested changes, create package versions, etc. This project is crucial for the Salesforce community and me personally. I don't want to create a clone of it. Instead, I want to save your name the author of it. Let me know if you are interested, and don't hesitate to contact me via email to provide you with more information on how we could configure the maintenance process.
  3. If it blocks you, I could work on code coverage for the secrets package so that you would be able to promote the version

@ruslan-kurchenko

I think you misunderstood.

I'm not trying to release the "secrets package", just the main one.

However, when I create a package, it's not running the tests, even though I'm specifying --codecoverage

sfdx force:package:version:create -p env-vars -d env-vars -x --wait 100 --codecoverage

I'm trying to troubleshoot, but honestly I don't have time to try and debug sfdx-cli issues. There doesn't seem to be much info online regarding it

@ruslan-kurchenko ahh the "secrets" class (part of the main package) had no test coverage (as you can see in your image).

I added tests and it allowed me to promote.

The new package id is in the readme