Azure / azure-service-operator

Azure Service Operator allows you to create Azure resources using kubectl
https://azure.github.io/azure-service-operator/
MIT License
776 stars 201 forks source link

Improve testing of import azure-resource #3214

Open theunrepentantgeek opened 1 year ago

theunrepentantgeek commented 1 year ago

Describe the current behavior

The code to import an Azure resource currently lacks in testing. We should fix that.

On #3212, #matthchr wrote:

Lacking a test related to this problem. I see that (like the core logic of the controller) it's somewhat difficult to unit test this code as it stands today. In the controller though we do have the recording tests to fall back on. Wondering here if we should define an interface that allows us to mock certain errors from Azure for aid in testing these cases? We actually already have one in extensions.ImporterFunc ... possibly we could leverage that with some test helpers to make it ergonomic to mock certain error responses from Azure and ensure we handle them?

Describe the improvement

Adding unit tests will insulate us against future maintenance issues.

matthchr commented 9 months ago

This is something we want to do still

matthchr commented 9 months ago

Somewhat related to #3399 in that possibly we can export this as a library and test it at the same time

matthchr commented 8 months ago

We still want to do this

theunrepentantgeek commented 5 months ago

We should also consider doing recorded tests, capturing the full interaction with ARM.

We'd likely have caught the issues leading to #3805 if we'd done this.