renoki-co / php-k8s

Unofficial PHP client for Kubernetes. It supports any form of authentication, the exec API, and it has an easy implementation for CRDs.
Apache License 2.0
310 stars 59 forks source link

[enhancement] Mocking during testing #211

Closed georgeboot closed 1 year ago

georgeboot commented 2 years ago

I would love to test our code that implements this package. However, I can't seem to find an easy way to mock this package cq the underlying HTTP client.

What approach are others using?

stale[bot] commented 2 years ago

This issue has been automatically closed because it has not had any recent activity. 😨

rennokki commented 2 years ago

I got an eye on @Sammyjo20's Saloon package and might use it. 😁

Sammyjo20 commented 2 years ago

@rennokki if you want an example or two of how I set up mocking for my SDKs just let me know!

stale[bot] commented 2 years ago

This issue has been automatically closed because it has not had any recent activity. 😨

Sammyjo20 commented 2 years ago

Hey @rennokki just got notified about this issue, it’s been a while since we last spoke about it and Saloon has matured a lot in the time!

I built an SDK template repo which you can use and it has support for mocking out of the box. You can do

$sdk = new SDK() $sdk->withMockClient($mockClient)

$sdk->request(new MyRequest)

// Or configure request collections

$sdk->users()->all()

The SDK repo is here but it’s all covered in the docs too 😀

https://github.com/Sammyjo20/saloon-sdk-template

stale[bot] commented 2 years ago

This issue has been automatically closed because it has not had any recent activity. 😨

Sammyjo20 commented 1 year ago

Hey @rennokki I saw that you reopened the issue, Saloon v2 is on the horizon (before the end of the year) so that might be an exciting moment to consider using it again, but if you are interested in Mocking I've recently built a really cool Fixture recording feature that might help!

https://docs.saloon.dev/next-steps/testing-faking-responses/recording-requests

rennokki commented 1 year ago

@Sammyjo20 Yeah, I actually reconsidered it since I've recently came back to become more involved into the project, so first steps are to have a proper cleanup of the issues and prioritize fixes, and take care of features and enhancements afterwards. :D

If you got the beta version, I might as well use it (with the risk of breaks) and merge it once the first few releases of v2 are published.

Sammyjo20 commented 1 year ago

That’s awesome!! I haven’t written the updated docs yet but as soon as I do that, I’ll tag a beta. You can start using the v2 branch now if you like but it may be a bit tricky without docs. You can always message me on Twitter :)

stale[bot] commented 1 year ago

This issue has been automatically closed because it has not had any recent activity. 😨

georgeboot commented 1 year ago

@rennokki do you still have plans to start using Saloon for this package?

Sammyjo20 commented 1 year ago

Just to let you know I intent to release the beta for Saloon v2 this week, the docs are still work-in-progress but all the basics are covered

Sammyjo20 commented 1 year ago

The v2 beta is now ready and most of the docs are up ⬆️ https://docs.saloon.dev/v/2