choco icon indicating copy to clipboard operation
choco copied to clipboard

PushCommand tests should push to a mocked endpoint and not Chocolatey Community Repository

Open corbob opened this issue 3 years ago • 5 comments

Is Your Feature Request Related To A Problem? Please describe.

Currently PushCommand tests require an API Key to push to the Chocolatey Community Repository. This means that community members are not able to run the full test suite as they do not have access to this API Key.

Describe The Solution. Why is it needed?

PowerShell has the ability to respond to HTTP requests. We could therefore have our tests listen for Chocolatey to push a package to it and respond with exactly the message we want.

Additional Context.

NA

Related Issues

NA

corbob avatar Nov 21 '22 19:11 corbob

Tangentially related to this: the BeforeDiscovery I believe was directly copied from the Licensed Push tests, as such, it contains some variables and checks that are not actually used in here.

https://github.com/chocolatey/choco/blob/345ef4eb9728881400fca31de34858de6839fda6/tests/chocolatey-tests/commands/choco-push.Tests.ps1#L4-L12

corbob avatar Dec 13 '22 19:12 corbob

@corbob what are your thoughts on this one? Is this still planned/required, or is the work that you have completed recently enough to allow community maintainers to control which endpoint is pushed to?

gep13 avatar Jan 24 '23 08:01 gep13

@corbob still looking for an answer to this?

pauby avatar May 11 '25 18:05 pauby

I think the idea I initially had for this was to mock a CCR response, and then test that both CLI hit the mock endpoint, and that it reported what it was expected to report.

But that might also be much easier said than done. The experimentation I did with PowerShell required a second PowerShell process.

I would be comfortable closing this as there hasn't really been a need for others to run the PushCommand tests in 2 years.

corbob avatar May 13 '25 02:05 corbob

If that is the path that you want to go down, you might be able to use WireMock.Net, in the same way that the Unit/Integration Tests are. It might require a bit more setup when being used outside of that context, but it might still work.

gep13 avatar May 13 '25 06:05 gep13