Repository navigation
Added test function to state module - #56298
Conversation
There was a problem hiding this comment.
I'm really not sure if the capturing/setting/resetting of __opts__["test"] is actually needed so I added it just in case. It's not being set in the usual place in this case so I think it does probably need to be set but I'm not sure if this is the correct method.
|
@raddessi Please add some tests. |
|
@twangboy I've tried to get the dev environment up multiple times in the past but always run in to issues, can you point me to docs? I've seen nothing on https://docs.saltstack.com/en/master/topics/tutorials/writing_tests.html about how to get the test env up. What I have tried is either |
|
Some info: |
|
I've been able to get tests running on Windows by running the following: Then I run a single tests like this: |
|
OK thanks for that bit, I'm able to run them now. I'm not incredibly familiar with the test setup here, what is the syntax to check that the sls/highstate fns were called with |
|
If you're running unit tests, you usually have to mock that. Here's code from one of the LGPO tests I have: |
Wouldn't that force it to run with |
|
I guess I misunderstood what you're testing... |
|
Hmm.. So take this example: Inside that |
|
Ah.. should I use |
|
That did it :) Thank you again! |
Ch3LL
left a comment
There was a problem hiding this comment.
thanks for this :) Since we want to ensure this does not break for users in the future could we also add an integration test for added measure. You can take a look at this file: tests/integration/modules/test_state.py to add a test here to ensure we do indeed run in test mode when running this.
Also one more ask. I would love to see this highlighted in the sodium release notes doc/topics/releases/sodium.rst
|
OK everything requested is done afaik. I'm really not sure how to word the release notes bit, feel free to change it up. |
Ch3LL
left a comment
There was a problem hiding this comment.
Thanks for this! tests look great :)
There is just a lint failure and a conflict that needs to be resolved if you could please rebase and resolve conflict. Thanks again!
|
I fear I've messed up the commit log, is this PR really meant to show 103 files changed? |
|
ya looks like there was an issue when you rebased most likely, it should only show your changes |
|
@raddessi just bumping here again to see if you can clean up the rebase. would love to get this in |
|
Yeah im so sorry, this last week i kept trying to find time. Ill try to get it in by eod
Sent from ProtonMail mobile
…-------- Original Message --------
On Mar 30, 2020, 9:00 AM, Megan Wilhite wrote:
***@***.***(https://github.com/raddessi) just bumping here again to see if you can clean up the rebase. would love to get this in
—
You are receiving this because you were mentioned.
Reply to this email directly, [view it on GitHub](#56298 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/ABTCBHWHNF4T36NKSJJ72WLRKCX2VANCNFSM4LAR2LDQ).
|
0eec0e2 to
75615a6
Compare
|
I'm guessing you don't mind that I reset history in my local branch right? Just checking, I've not messed up this bad on github before but this seems safe to me. |
|
ya rebase looks good thanks @raddessi . looks like there's just a lint failure remaining to be cleaned up. Thanks for your work on this :) |
|
Sorry about that, the linting fix must have been lost in the rebase fix. Should be cleared up now @Ch3LL |
|
Huge thank you to all involved with sep 15 |
|
BTW, I had to uninstall my precommit hook for this repo, it was giving me linter errors from tons of files I hadn't modified. Is the precommit config here not fully implemented/maintained yet? |
|
apologies on the inconvenience. It should be full implemented although we are waiting on this: #56578 to add a jenkins job to run on the PRs. It shouldn't be giving you lint errors. Have you re-based with the latest changes? Feel free to reach out to me on the community slack (ch3ll there as well) and we can work it out so we can make this less of a pain. |
|
Oh no worries :) That's great! I had no idea there was any slack besides the NTC which I was already on. I've joined that now also. I must have missed that in the docs. I'll try re-adding precommit after I pull down a fresh copy of this branch |
|
ping @twangboy this is just awaiting your review and we can get this merged in. |
What does this PR do?
This adds a
state.testmodule as an alias tostate.apply test=True. This is easier to type and even better avoids typos when specifyingtest=Trueon the cli, such as when I ran withtesdt=True. This was originally an idea I saw from #51932 but when I search for an open PR to track it I didn't see one so I wrote this up myself as I thought it was a great idea.What issues does this PR fix or reference?
#51932
Previous Behavior
You would run
state.apply test=Trueto test a state. This still allows for that, but provides a handy alias as well.New Behavior
Now you can run
state.testas a shorthand.Tests written?
No, the whole test setup here has had me confused in the past but I'll set something up if you point me to how the pytest tests work now.
Commits signed with GPG?
No