core: Don't panic in TestContext2Apply_dataDependsOn if data source fails

This commit is contained in:
Martin Atkins 2018-10-02 15:21:10 -07:00
parent 412439ae01
commit 8ada1bd712

View File

@ -9276,8 +9276,16 @@ func TestContext2Apply_dataDependsOn(t *testing.T) {
assertNoErrors(t, diags)
root := state.Module(addrs.RootModuleInstance)
is := root.ResourceInstance(addrs.Resource{
Mode: addrs.DataResourceMode,
Type: "null_data_source",
Name: "read",
}.Instance(addrs.NoKey))
if is == nil {
t.Fatal("data resource instance is not present in state; should be")
}
var attrs map[string]interface{}
err := json.Unmarshal(root.Resources["data.null_data_source.read"].Instances[addrs.NoKey].Current.AttrsJSON, &attrs)
err := json.Unmarshal(is.Current.AttrsJSON, &attrs)
if err != nil {
t.Fatal(err)
}