{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/890","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/890/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/890/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/890/events","html_url":"https://github.com/hashicorp/terraform/issues/890","id":55919671,"number":890,"title":"Provider's CRUD functions are difficult to unit test","user":{"login":"bitglue","id":1232472,"avatar_url":"https://avatars.githubusercontent.com/u/1232472?v=3","gravatar_id":"","url":"https://api.github.com/users/bitglue","html_url":"https://github.com/bitglue","followers_url":"https://api.github.com/users/bitglue/followers","following_url":"https://api.github.com/users/bitglue/following{/other_user}","gists_url":"https://api.github.com/users/bitglue/gists{/gist_id}","starred_url":"https://api.github.com/users/bitglue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitglue/subscriptions","organizations_url":"https://api.github.com/users/bitglue/orgs","repos_url":"https://api.github.com/users/bitglue/repos","events_url":"https://api.github.com/users/bitglue/events{/privacy}","received_events_url":"https://api.github.com/users/bitglue/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hashicorp/terraform/labels/core","name":"core","color":"cccccc"},{"url":"https://api.github.com/repos/hashicorp/terraform/labels/enhancement","name":"enhancement","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-01-29T16:14:28Z","updated_at":"2015-11-23T17:15:48Z","closed_at":null,"body":"This could be my inexperience with Go, but I find it very difficult to unit test provider CRUD functions. The reason is that they take a `*schema.ResourceData` parameter, but a lot of the fields in that type are private. Thus, it's not possible to construct a `ResourceData` out of tree for testing.\r\n\r\nWould it make sense to define an interface for the thing given to the CRUD operations? Out-of-tree providers would then be able to make mock implementations and unit testing would be much simpler. I guess such a change would be an incompatible change to the provider API, but one that's easily fixed by changing the signature of the CRUD functions. Not sure how much of a concern that is.\r\n\r\nI'll give implementing this a shot if it seems like a good idea."},"comment":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/158999938","html_url":"https://github.com/hashicorp/terraform/issues/890#issuecomment-158999938","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/890","id":158999938,"user":{"login":"phinze","id":37534,"avatar_url":"https://avatars.githubusercontent.com/u/37534?v=3","gravatar_id":"","url":"https://api.github.com/users/phinze","html_url":"https://github.com/phinze","followers_url":"https://api.github.com/users/phinze/followers","following_url":"https://api.github.com/users/phinze/following{/other_user}","gists_url":"https://api.github.com/users/phinze/gists{/gist_id}","starred_url":"https://api.github.com/users/phinze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phinze/subscriptions","organizations_url":"https://api.github.com/users/phinze/orgs","repos_url":"https://api.github.com/users/phinze/repos","events_url":"https://api.github.com/users/phinze/events{/privacy}","received_events_url":"https://api.github.com/users/phinze/received_events","type":"User","site_admin":false},"created_at":"2015-11-23T17:15:48Z","updated_at":"2015-11-23T17:15:48Z","body":"@bitglue ah sorry I've been flying through old issues and misread this description as encompassing the interface solution. We still don't have a good way of unit testing providers today, I'll reopen this until we come up with a story there. :+1: "}}