|
| 1 | +// Copyright (c) HashiCorp, Inc. |
| 2 | +// SPDX-License-Identifier: MPL-2.0 |
| 3 | + |
| 4 | +package querycheck_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/list" |
| 11 | + "github.com/hashicorp/terraform-plugin-testing/internal/teststep" |
| 12 | +) |
| 13 | + |
| 14 | +func examplecloudListResource() testprovider.ListResource { |
| 15 | + return testprovider.ListResource{ |
| 16 | + IncludeResource: true, |
| 17 | + SchemaResponse: &list.SchemaResponse{ |
| 18 | + Schema: &tfprotov6.Schema{ |
| 19 | + Block: &tfprotov6.SchemaBlock{ |
| 20 | + Attributes: []*tfprotov6.SchemaAttribute{ |
| 21 | + { |
| 22 | + Name: "resource_group_name", |
| 23 | + Type: tftypes.String, |
| 24 | + Required: true, |
| 25 | + }, |
| 26 | + }, |
| 27 | + }, |
| 28 | + }, |
| 29 | + }, |
| 30 | + ListResultsStream: &list.ListResultsStream{ |
| 31 | + Results: func(push func(list.ListResult) bool) { |
| 32 | + push(list.ListResult{ |
| 33 | + Resource: teststep.Pointer(tftypes.NewValue( |
| 34 | + tftypes.Object{ |
| 35 | + AttributeTypes: map[string]tftypes.Type{ |
| 36 | + "id": tftypes.String, |
| 37 | + "location": tftypes.String, |
| 38 | + "name": tftypes.String, |
| 39 | + "resource_group_name": tftypes.String, |
| 40 | + "instances": tftypes.Number, |
| 41 | + }, |
| 42 | + }, |
| 43 | + map[string]tftypes.Value{ |
| 44 | + "id": tftypes.NewValue(tftypes.String, "foo/banane"), |
| 45 | + "location": tftypes.NewValue(tftypes.String, "westeurope"), |
| 46 | + "name": tftypes.NewValue(tftypes.String, "banane"), |
| 47 | + "resource_group_name": tftypes.NewValue(tftypes.String, "foo"), |
| 48 | + "instances": tftypes.NewValue(tftypes.Number, 5), |
| 49 | + }, |
| 50 | + )), |
| 51 | + Identity: teststep.Pointer(tftypes.NewValue( |
| 52 | + tftypes.Object{ |
| 53 | + AttributeTypes: map[string]tftypes.Type{ |
| 54 | + "resource_group_name": tftypes.String, |
| 55 | + "name": tftypes.String, |
| 56 | + }, |
| 57 | + }, |
| 58 | + map[string]tftypes.Value{ |
| 59 | + "resource_group_name": tftypes.NewValue(tftypes.String, "foo"), |
| 60 | + "name": tftypes.NewValue(tftypes.String, "banane"), |
| 61 | + }, |
| 62 | + )), |
| 63 | + DisplayName: "banane", |
| 64 | + }) |
| 65 | + push(list.ListResult{ |
| 66 | + Resource: teststep.Pointer(tftypes.NewValue( |
| 67 | + tftypes.Object{ |
| 68 | + AttributeTypes: map[string]tftypes.Type{ |
| 69 | + "id": tftypes.String, |
| 70 | + "location": tftypes.String, |
| 71 | + "name": tftypes.String, |
| 72 | + "resource_group_name": tftypes.String, |
| 73 | + "instances": tftypes.Number, |
| 74 | + }, |
| 75 | + }, |
| 76 | + map[string]tftypes.Value{ |
| 77 | + "id": tftypes.NewValue(tftypes.String, "foo/ananas"), |
| 78 | + "location": tftypes.NewValue(tftypes.String, "westeurope"), |
| 79 | + "name": tftypes.NewValue(tftypes.String, "ananas"), |
| 80 | + "resource_group_name": tftypes.NewValue(tftypes.String, "foo"), |
| 81 | + "instances": tftypes.NewValue(tftypes.Number, 9000), |
| 82 | + }, |
| 83 | + )), |
| 84 | + Identity: teststep.Pointer(tftypes.NewValue( |
| 85 | + tftypes.Object{ |
| 86 | + AttributeTypes: map[string]tftypes.Type{ |
| 87 | + "resource_group_name": tftypes.String, |
| 88 | + "name": tftypes.String, |
| 89 | + }, |
| 90 | + }, |
| 91 | + map[string]tftypes.Value{ |
| 92 | + "resource_group_name": tftypes.NewValue(tftypes.String, "foo"), |
| 93 | + "name": tftypes.NewValue(tftypes.String, "ananas"), |
| 94 | + }, |
| 95 | + )), |
| 96 | + DisplayName: "ananas", |
| 97 | + }) |
| 98 | + push(list.ListResult{ |
| 99 | + Resource: teststep.Pointer(tftypes.NewValue( |
| 100 | + tftypes.Object{ |
| 101 | + AttributeTypes: map[string]tftypes.Type{ |
| 102 | + "id": tftypes.String, |
| 103 | + "location": tftypes.String, |
| 104 | + "name": tftypes.String, |
| 105 | + "resource_group_name": tftypes.String, |
| 106 | + "instances": tftypes.Number, |
| 107 | + }, |
| 108 | + }, |
| 109 | + map[string]tftypes.Value{ |
| 110 | + "id": tftypes.NewValue(tftypes.String, "foo/kiwi"), |
| 111 | + "location": tftypes.NewValue(tftypes.String, "westeurope"), |
| 112 | + "name": tftypes.NewValue(tftypes.String, "kiwi"), |
| 113 | + "resource_group_name": tftypes.NewValue(tftypes.String, "foo"), |
| 114 | + "instances": tftypes.NewValue(tftypes.Number, 88), |
| 115 | + }, |
| 116 | + )), |
| 117 | + Identity: teststep.Pointer(tftypes.NewValue( |
| 118 | + tftypes.Object{ |
| 119 | + AttributeTypes: map[string]tftypes.Type{ |
| 120 | + "resource_group_name": tftypes.String, |
| 121 | + "name": tftypes.String, |
| 122 | + }, |
| 123 | + }, |
| 124 | + map[string]tftypes.Value{ |
| 125 | + "resource_group_name": tftypes.NewValue(tftypes.String, "foo"), |
| 126 | + "name": tftypes.NewValue(tftypes.String, "kiwi"), |
| 127 | + }, |
| 128 | + )), |
| 129 | + DisplayName: "kiwi", |
| 130 | + }) |
| 131 | + push(list.ListResult{ |
| 132 | + Resource: teststep.Pointer(tftypes.NewValue( |
| 133 | + tftypes.Object{ |
| 134 | + AttributeTypes: map[string]tftypes.Type{ |
| 135 | + "id": tftypes.String, |
| 136 | + "location": tftypes.String, |
| 137 | + "name": tftypes.String, |
| 138 | + "resource_group_name": tftypes.String, |
| 139 | + "instances": tftypes.Number, |
| 140 | + }, |
| 141 | + }, |
| 142 | + map[string]tftypes.Value{ |
| 143 | + "id": tftypes.NewValue(tftypes.String, "bar/papaya"), |
| 144 | + "location": tftypes.NewValue(tftypes.String, "westeurope"), |
| 145 | + "name": tftypes.NewValue(tftypes.String, "banane"), |
| 146 | + "resource_group_name": tftypes.NewValue(tftypes.String, "foo"), |
| 147 | + "instances": tftypes.NewValue(tftypes.Number, 3), |
| 148 | + }, |
| 149 | + )), |
| 150 | + Identity: teststep.Pointer(tftypes.NewValue( |
| 151 | + tftypes.Object{ |
| 152 | + AttributeTypes: map[string]tftypes.Type{ |
| 153 | + "resource_group_name": tftypes.String, |
| 154 | + "name": tftypes.String, |
| 155 | + }, |
| 156 | + }, |
| 157 | + map[string]tftypes.Value{ |
| 158 | + "resource_group_name": tftypes.NewValue(tftypes.String, "bar"), |
| 159 | + "name": tftypes.NewValue(tftypes.String, "papaya"), |
| 160 | + }, |
| 161 | + )), |
| 162 | + DisplayName: "papaya", |
| 163 | + }) |
| 164 | + push(list.ListResult{ |
| 165 | + Resource: teststep.Pointer(tftypes.NewValue( |
| 166 | + tftypes.Object{ |
| 167 | + AttributeTypes: map[string]tftypes.Type{ |
| 168 | + "id": tftypes.String, |
| 169 | + "location": tftypes.String, |
| 170 | + "name": tftypes.String, |
| 171 | + "resource_group_name": tftypes.String, |
| 172 | + "instances": tftypes.Number, |
| 173 | + }, |
| 174 | + }, |
| 175 | + map[string]tftypes.Value{ |
| 176 | + "id": tftypes.NewValue(tftypes.String, "bar/birne"), |
| 177 | + "location": tftypes.NewValue(tftypes.String, "westeurope"), |
| 178 | + "name": tftypes.NewValue(tftypes.String, "birne"), |
| 179 | + "resource_group_name": tftypes.NewValue(tftypes.String, "foo"), |
| 180 | + "instances": tftypes.NewValue(tftypes.Number, 8564), |
| 181 | + }, |
| 182 | + )), |
| 183 | + Identity: teststep.Pointer(tftypes.NewValue( |
| 184 | + tftypes.Object{ |
| 185 | + AttributeTypes: map[string]tftypes.Type{ |
| 186 | + "resource_group_name": tftypes.String, |
| 187 | + "name": tftypes.String, |
| 188 | + }, |
| 189 | + }, |
| 190 | + map[string]tftypes.Value{ |
| 191 | + "resource_group_name": tftypes.NewValue(tftypes.String, "bar"), |
| 192 | + "name": tftypes.NewValue(tftypes.String, "birne"), |
| 193 | + }, |
| 194 | + )), |
| 195 | + DisplayName: "birne", |
| 196 | + }) |
| 197 | + push(list.ListResult{ |
| 198 | + Resource: teststep.Pointer(tftypes.NewValue( |
| 199 | + tftypes.Object{ |
| 200 | + AttributeTypes: map[string]tftypes.Type{ |
| 201 | + "id": tftypes.String, |
| 202 | + "location": tftypes.String, |
| 203 | + "name": tftypes.String, |
| 204 | + "resource_group_name": tftypes.String, |
| 205 | + "instances": tftypes.Number, |
| 206 | + }, |
| 207 | + }, |
| 208 | + map[string]tftypes.Value{ |
| 209 | + "id": tftypes.NewValue(tftypes.String, "bar/kirsche"), |
| 210 | + "location": tftypes.NewValue(tftypes.String, "westeurope"), |
| 211 | + "name": tftypes.NewValue(tftypes.String, "kirsche"), |
| 212 | + "resource_group_name": tftypes.NewValue(tftypes.String, "foo"), |
| 213 | + "instances": tftypes.NewValue(tftypes.Number, 500), |
| 214 | + }, |
| 215 | + )), |
| 216 | + Identity: teststep.Pointer(tftypes.NewValue( |
| 217 | + tftypes.Object{ |
| 218 | + AttributeTypes: map[string]tftypes.Type{ |
| 219 | + "resource_group_name": tftypes.String, |
| 220 | + "name": tftypes.String, |
| 221 | + }, |
| 222 | + }, |
| 223 | + map[string]tftypes.Value{ |
| 224 | + "resource_group_name": tftypes.NewValue(tftypes.String, "bar"), |
| 225 | + "name": tftypes.NewValue(tftypes.String, "kirsche"), |
| 226 | + }, |
| 227 | + )), |
| 228 | + DisplayName: "kirsche", |
| 229 | + }) |
| 230 | + }, |
| 231 | + }, |
| 232 | + } |
| 233 | +} |
0 commit comments