Discussion: testing resources
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..
- do we need to poke
schema.Resource.Diff()andschema.Resource.Apply()ourselves? - would it be better to use the
resource.Testacceptance test framework along with the fake client? - is this going too much against the grain of Terraform, who typically only use acceptance tests against real APIs, and should we do that instead of unit testing?
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 ?