|
| 1 | +// Copyright (c) HashiCorp, Inc. |
| 2 | +// SPDX-License-Identifier: MPL-2.0 |
| 3 | + |
| 4 | +package query_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: "id", |
| 23 | + Type: tftypes.String, |
| 24 | + Computed: 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 | + }, |
| 40 | + }, |
| 41 | + map[string]tftypes.Value{ |
| 42 | + "id": tftypes.NewValue(tftypes.String, "westeurope/somevalue"), |
| 43 | + "location": tftypes.NewValue(tftypes.String, "westeurope"), |
| 44 | + "name": tftypes.NewValue(tftypes.String, "somevalue"), |
| 45 | + }, |
| 46 | + )), |
| 47 | + Identity: teststep.Pointer(tftypes.NewValue( |
| 48 | + tftypes.Object{ |
| 49 | + AttributeTypes: map[string]tftypes.Type{ |
| 50 | + "id": tftypes.String, |
| 51 | + "location": tftypes.String, |
| 52 | + }, |
| 53 | + }, |
| 54 | + map[string]tftypes.Value{ |
| 55 | + "id": tftypes.NewValue(tftypes.String, "westeurope/somevalue1"), |
| 56 | + "location": tftypes.NewValue(tftypes.String, "westeurope"), |
| 57 | + }, |
| 58 | + )), |
| 59 | + }) |
| 60 | + push(list.ListResult{ |
| 61 | + Identity: teststep.Pointer(tftypes.NewValue( |
| 62 | + tftypes.Object{ |
| 63 | + AttributeTypes: map[string]tftypes.Type{ |
| 64 | + "id": tftypes.String, |
| 65 | + "location": tftypes.String, |
| 66 | + }, |
| 67 | + }, |
| 68 | + map[string]tftypes.Value{ |
| 69 | + "id": tftypes.NewValue(tftypes.String, "westeurope/somevalue2"), |
| 70 | + "location": tftypes.NewValue(tftypes.String, "westeurope2"), |
| 71 | + }, |
| 72 | + )), |
| 73 | + }) |
| 74 | + push(list.ListResult{ |
| 75 | + Identity: teststep.Pointer(tftypes.NewValue( |
| 76 | + tftypes.Object{ |
| 77 | + AttributeTypes: map[string]tftypes.Type{ |
| 78 | + "id": tftypes.String, |
| 79 | + "location": tftypes.String, |
| 80 | + }, |
| 81 | + }, |
| 82 | + map[string]tftypes.Value{ |
| 83 | + "id": tftypes.NewValue(tftypes.String, "westeurope/somevalue3"), |
| 84 | + "location": tftypes.NewValue(tftypes.String, "westeurope3"), |
| 85 | + }, |
| 86 | + )), |
| 87 | + }) |
| 88 | + }, |
| 89 | + }, |
| 90 | + } |
| 91 | +} |
0 commit comments