|
| 1 | +// Copyright (c) HashiCorp, Inc. |
| 2 | +// SPDX-License-Identifier: MPL-2.0 |
| 3 | + |
| 4 | +package importstate_test |
| 5 | + |
| 6 | +import ( |
| 7 | + "github.com/hashicorp/terraform-plugin-go/tfprotov6" |
| 8 | + "github.com/hashicorp/terraform-plugin-go/tftypes" |
| 9 | + "github.com/hashicorp/terraform-plugin-testing/internal/testing/testprovider" |
| 10 | + "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/datasource" |
| 11 | + "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/resource" |
| 12 | +) |
| 13 | + |
| 14 | +func examplecloudDataSource() testprovider.DataSource { |
| 15 | + return testprovider.DataSource{ |
| 16 | + ReadResponse: &datasource.ReadResponse{ |
| 17 | + State: tftypes.NewValue( |
| 18 | + tftypes.Object{ |
| 19 | + AttributeTypes: map[string]tftypes.Type{ |
| 20 | + "id": tftypes.String, |
| 21 | + }, |
| 22 | + }, |
| 23 | + map[string]tftypes.Value{ |
| 24 | + "id": tftypes.NewValue(tftypes.String, "datasource-test"), |
| 25 | + }, |
| 26 | + ), |
| 27 | + }, |
| 28 | + SchemaResponse: &datasource.SchemaResponse{ |
| 29 | + Schema: &tfprotov6.Schema{ |
| 30 | + Block: &tfprotov6.SchemaBlock{ |
| 31 | + Attributes: []*tfprotov6.SchemaAttribute{ |
| 32 | + { |
| 33 | + Name: "id", |
| 34 | + Type: tftypes.String, |
| 35 | + Computed: true, |
| 36 | + }, |
| 37 | + }, |
| 38 | + }, |
| 39 | + }, |
| 40 | + }, |
| 41 | + } |
| 42 | +} |
| 43 | + |
| 44 | +func examplecloudResource() testprovider.Resource { |
| 45 | + return testprovider.Resource{ |
| 46 | + CreateResponse: &resource.CreateResponse{ |
| 47 | + NewState: tftypes.NewValue( |
| 48 | + tftypes.Object{ |
| 49 | + AttributeTypes: map[string]tftypes.Type{ |
| 50 | + "id": tftypes.String, |
| 51 | + "location": tftypes.String, |
| 52 | + "name": tftypes.String, |
| 53 | + }, |
| 54 | + }, |
| 55 | + map[string]tftypes.Value{ |
| 56 | + "id": tftypes.NewValue(tftypes.String, "westeurope/somevalue"), |
| 57 | + "location": tftypes.NewValue(tftypes.String, "westeurope"), |
| 58 | + "name": tftypes.NewValue(tftypes.String, "somevalue"), |
| 59 | + }, |
| 60 | + ), |
| 61 | + }, |
| 62 | + ReadResponse: &resource.ReadResponse{ |
| 63 | + NewState: tftypes.NewValue( |
| 64 | + tftypes.Object{ |
| 65 | + AttributeTypes: map[string]tftypes.Type{ |
| 66 | + "id": tftypes.String, |
| 67 | + "location": tftypes.String, |
| 68 | + "name": tftypes.String, |
| 69 | + }, |
| 70 | + }, |
| 71 | + map[string]tftypes.Value{ |
| 72 | + "id": tftypes.NewValue(tftypes.String, "westeurope/somevalue"), |
| 73 | + "location": tftypes.NewValue(tftypes.String, "westeurope"), |
| 74 | + "name": tftypes.NewValue(tftypes.String, "somevalue"), |
| 75 | + }, |
| 76 | + ), |
| 77 | + }, |
| 78 | + ImportStateResponse: &resource.ImportStateResponse{ |
| 79 | + State: tftypes.NewValue( |
| 80 | + tftypes.Object{ |
| 81 | + AttributeTypes: map[string]tftypes.Type{ |
| 82 | + "id": tftypes.String, |
| 83 | + "location": tftypes.String, |
| 84 | + "name": tftypes.String, |
| 85 | + }, |
| 86 | + }, |
| 87 | + map[string]tftypes.Value{ |
| 88 | + "id": tftypes.NewValue(tftypes.String, "westeurope/somevalue"), |
| 89 | + "location": tftypes.NewValue(tftypes.String, "westeurope"), |
| 90 | + "name": tftypes.NewValue(tftypes.String, "somevalue"), |
| 91 | + }, |
| 92 | + ), |
| 93 | + }, |
| 94 | + SchemaResponse: &resource.SchemaResponse{ |
| 95 | + Schema: &tfprotov6.Schema{ |
| 96 | + Block: &tfprotov6.SchemaBlock{ |
| 97 | + Attributes: []*tfprotov6.SchemaAttribute{ |
| 98 | + { |
| 99 | + Name: "id", |
| 100 | + Type: tftypes.String, |
| 101 | + Computed: true, |
| 102 | + }, |
| 103 | + { |
| 104 | + Name: "location", |
| 105 | + Type: tftypes.String, |
| 106 | + Required: true, |
| 107 | + }, |
| 108 | + { |
| 109 | + Name: "name", |
| 110 | + Type: tftypes.String, |
| 111 | + Required: true, |
| 112 | + }, |
| 113 | + }, |
| 114 | + }, |
| 115 | + }, |
| 116 | + }, |
| 117 | + } |
| 118 | +} |
0 commit comments