orange-cloudfoundry / terraform-provider-cloudfoundry

A terraform provider to manage a Cloud Foundry instance.
Apache License 2.0
31 stars 8 forks source link

Discussion: testing resources #17

Open dcarley opened 7 years ago

dcarley commented 7 years ago

I've noticed in the unit tests that do:

resource = LoadCfResource(CfBuildpackResource{})
resourceData = resource.Data(&terraform.InstanceState{})

It's not possible to test an resource.Update() method which uses resourceData.HasChange() because resourceData doesn't have any record of the before and after diff.

Do you have any thoughts about how it might be possible to implement a more realistic test? I was wondering..

ArthurHlt commented 7 years ago

As you can see I've didn't do the Update case in unit test, I had this issue and that's really good that you leverage this point. I need more your opinion to know what we should do for tests, if we try to mock or directly use their kind of framework. I've didn't use it because first I thought I could do without and have a better usecases cover but it seems quite hard to mock and so on. So what do you think ?