Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 162 additions & 20 deletions helper/resource/query/examplecloud_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ func examplecloudListResource() testprovider.ListResource {
Block: &tfprotov6.SchemaBlock{
Attributes: []*tfprotov6.SchemaAttribute{
{
Name: "id",
Name: "resource_group_name",
Type: tftypes.String,
Computed: true,
Required: true,
},
},
},
Expand All @@ -33,57 +33,199 @@ func examplecloudListResource() testprovider.ListResource {
Resource: teststep.Pointer(tftypes.NewValue(
tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"id": tftypes.String,
"location": tftypes.String,
"name": tftypes.String,
"id": tftypes.String,
"location": tftypes.String,
"name": tftypes.String,
"resource_group_name": tftypes.String,
"instances": tftypes.Number,
},
},
map[string]tftypes.Value{
"id": tftypes.NewValue(tftypes.String, "westeurope/somevalue"),
"location": tftypes.NewValue(tftypes.String, "westeurope"),
"name": tftypes.NewValue(tftypes.String, "somevalue"),
"id": tftypes.NewValue(tftypes.String, "foo/banane"),
"location": tftypes.NewValue(tftypes.String, "westeurope"),
"name": tftypes.NewValue(tftypes.String, "banane"),
"resource_group_name": tftypes.NewValue(tftypes.String, "foo"),
"instances": tftypes.NewValue(tftypes.Number, 5),
},
)),
Identity: teststep.Pointer(tftypes.NewValue(
tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"id": tftypes.String,
"location": tftypes.String,
"resource_group_name": tftypes.String,
"name": tftypes.String,
},
},
map[string]tftypes.Value{
"id": tftypes.NewValue(tftypes.String, "westeurope/somevalue1"),
"location": tftypes.NewValue(tftypes.String, "westeurope"),
"resource_group_name": tftypes.NewValue(tftypes.String, "foo"),
"name": tftypes.NewValue(tftypes.String, "banane"),
},
)),
DisplayName: "banane",
})
push(list.ListResult{
Resource: teststep.Pointer(tftypes.NewValue(
tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"id": tftypes.String,
"location": tftypes.String,
"name": tftypes.String,
"resource_group_name": tftypes.String,
"instances": tftypes.Number,
},
},
map[string]tftypes.Value{
"id": tftypes.NewValue(tftypes.String, "foo/ananas"),
"location": tftypes.NewValue(tftypes.String, "westeurope"),
"name": tftypes.NewValue(tftypes.String, "ananas"),
"resource_group_name": tftypes.NewValue(tftypes.String, "foo"),
"instances": tftypes.NewValue(tftypes.Number, 9000),
},
)),
Identity: teststep.Pointer(tftypes.NewValue(
tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"resource_group_name": tftypes.String,
"name": tftypes.String,
},
},
map[string]tftypes.Value{
"resource_group_name": tftypes.NewValue(tftypes.String, "foo"),
"name": tftypes.NewValue(tftypes.String, "ananas"),
},
)),
DisplayName: "ananas",
})
push(list.ListResult{
Resource: teststep.Pointer(tftypes.NewValue(
tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"id": tftypes.String,
"location": tftypes.String,
"name": tftypes.String,
"resource_group_name": tftypes.String,
"instances": tftypes.Number,
},
},
map[string]tftypes.Value{
"id": tftypes.NewValue(tftypes.String, "foo/kiwi"),
"location": tftypes.NewValue(tftypes.String, "westeurope"),
"name": tftypes.NewValue(tftypes.String, "kiwi"),
"resource_group_name": tftypes.NewValue(tftypes.String, "foo"),
"instances": tftypes.NewValue(tftypes.Number, 88),
},
)),
Identity: teststep.Pointer(tftypes.NewValue(
tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"resource_group_name": tftypes.String,
"name": tftypes.String,
},
},
map[string]tftypes.Value{
"resource_group_name": tftypes.NewValue(tftypes.String, "foo"),
"name": tftypes.NewValue(tftypes.String, "kiwi"),
},
)),
DisplayName: "kiwi",
})
push(list.ListResult{
Resource: teststep.Pointer(tftypes.NewValue(
tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"id": tftypes.String,
"location": tftypes.String,
"name": tftypes.String,
"resource_group_name": tftypes.String,
"instances": tftypes.Number,
},
},
map[string]tftypes.Value{
"id": tftypes.NewValue(tftypes.String, "bar/papaya"),
"location": tftypes.NewValue(tftypes.String, "westeurope"),
"name": tftypes.NewValue(tftypes.String, "banane"),
"resource_group_name": tftypes.NewValue(tftypes.String, "foo"),
"instances": tftypes.NewValue(tftypes.Number, 3),
},
)),
Identity: teststep.Pointer(tftypes.NewValue(
tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"id": tftypes.String,
"location": tftypes.String,
"resource_group_name": tftypes.String,
"name": tftypes.String,
},
},
map[string]tftypes.Value{
"id": tftypes.NewValue(tftypes.String, "westeurope/somevalue2"),
"location": tftypes.NewValue(tftypes.String, "westeurope2"),
"resource_group_name": tftypes.NewValue(tftypes.String, "bar"),
"name": tftypes.NewValue(tftypes.String, "papaya"),
},
)),
DisplayName: "papaya",
})
push(list.ListResult{
Resource: teststep.Pointer(tftypes.NewValue(
tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"id": tftypes.String,
"location": tftypes.String,
"name": tftypes.String,
"resource_group_name": tftypes.String,
"instances": tftypes.Number,
},
},
map[string]tftypes.Value{
"id": tftypes.NewValue(tftypes.String, "bar/birne"),
"location": tftypes.NewValue(tftypes.String, "westeurope"),
"name": tftypes.NewValue(tftypes.String, "birne"),
"resource_group_name": tftypes.NewValue(tftypes.String, "foo"),
"instances": tftypes.NewValue(tftypes.Number, 8564),
},
)),
Identity: teststep.Pointer(tftypes.NewValue(
tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"resource_group_name": tftypes.String,
"name": tftypes.String,
},
},
map[string]tftypes.Value{
"resource_group_name": tftypes.NewValue(tftypes.String, "bar"),
"name": tftypes.NewValue(tftypes.String, "birne"),
},
)),
DisplayName: "birne",
})
push(list.ListResult{
Resource: teststep.Pointer(tftypes.NewValue(
tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"id": tftypes.String,
"location": tftypes.String,
"name": tftypes.String,
"resource_group_name": tftypes.String,
"instances": tftypes.Number,
},
},
map[string]tftypes.Value{
"id": tftypes.NewValue(tftypes.String, "bar/kirsche"),
"location": tftypes.NewValue(tftypes.String, "westeurope"),
"name": tftypes.NewValue(tftypes.String, "kirsche"),
"resource_group_name": tftypes.NewValue(tftypes.String, "foo"),
"instances": tftypes.NewValue(tftypes.Number, 500),
},
)),
Identity: teststep.Pointer(tftypes.NewValue(
tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"id": tftypes.String,
"location": tftypes.String,
"resource_group_name": tftypes.String,
"name": tftypes.String,
},
},
map[string]tftypes.Value{
"id": tftypes.NewValue(tftypes.String, "westeurope/somevalue3"),
"location": tftypes.NewValue(tftypes.String, "westeurope3"),
"resource_group_name": tftypes.NewValue(tftypes.String, "bar"),
"name": tftypes.NewValue(tftypes.String, "kirsche"),
},
)),
DisplayName: "kirsche",
})
},
},
Expand Down
78 changes: 46 additions & 32 deletions helper/resource/query/examplecloud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,83 +17,95 @@ func examplecloudResource() testprovider.Resource {
NewState: tftypes.NewValue(
tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"id": tftypes.String,
"location": tftypes.String,
"name": tftypes.String,
"id": tftypes.String,
"location": tftypes.String,
"name": tftypes.String,
"resource_group_name": tftypes.String,
"instances": tftypes.Number,
},
},
map[string]tftypes.Value{
"id": tftypes.NewValue(tftypes.String, "westeurope/somevalue"),
"location": tftypes.NewValue(tftypes.String, "westeurope"),
"name": tftypes.NewValue(tftypes.String, "somevalue"),
"id": tftypes.NewValue(tftypes.String, "foo/banana"),
"location": tftypes.NewValue(tftypes.String, "westeurope"),
"name": tftypes.NewValue(tftypes.String, "banana"),
"resource_group_name": tftypes.NewValue(tftypes.String, "foo"),
"instances": tftypes.NewValue(tftypes.Number, int64(5)),
},
),
NewIdentity: teststep.Pointer(tftypes.NewValue(
tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"id": tftypes.String,
"location": tftypes.String,
"resource_group_name": tftypes.String,
"name": tftypes.String,
},
},
map[string]tftypes.Value{
"id": tftypes.NewValue(tftypes.String, "westeurope/somevalue"),
"location": tftypes.NewValue(tftypes.String, "somelocation"),
"resource_group_name": tftypes.NewValue(tftypes.String, "foo"),
"name": tftypes.NewValue(tftypes.String, "banana"),
},
)),
},
ReadResponse: &resource.ReadResponse{
NewState: tftypes.NewValue(
tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"id": tftypes.String,
"location": tftypes.String,
"name": tftypes.String,
"id": tftypes.String,
"location": tftypes.String,
"name": tftypes.String,
"resource_group_name": tftypes.String,
"instances": tftypes.Number,
},
},
map[string]tftypes.Value{
"id": tftypes.NewValue(tftypes.String, "westeurope/somevalue"),
"location": tftypes.NewValue(tftypes.String, "westeurope"),
"name": tftypes.NewValue(tftypes.String, "somevalue"),
"id": tftypes.NewValue(tftypes.String, "foo/banana"),
"location": tftypes.NewValue(tftypes.String, "westeurope"),
"name": tftypes.NewValue(tftypes.String, "banana"),
"resource_group_name": tftypes.NewValue(tftypes.String, "foo"),
"instances": tftypes.NewValue(tftypes.Number, int64(5)),
},
),
NewIdentity: teststep.Pointer(tftypes.NewValue(
tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"id": tftypes.String,
"location": tftypes.String,
"resource_group_name": tftypes.String,
"name": tftypes.String,
},
},
map[string]tftypes.Value{
"id": tftypes.NewValue(tftypes.String, "westeurope/somevalue"),
"location": tftypes.NewValue(tftypes.String, "westeurope"),
"resource_group_name": tftypes.NewValue(tftypes.String, "foo"),
"name": tftypes.NewValue(tftypes.String, "banana"),
},
)),
},
ImportStateResponse: &resource.ImportStateResponse{
State: tftypes.NewValue(
tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"id": tftypes.String,
"location": tftypes.String,
"name": tftypes.String,
"id": tftypes.String,
"location": tftypes.String,
"name": tftypes.String,
"resource_group_name": tftypes.String,
"instances": tftypes.Number,
},
},
map[string]tftypes.Value{
"id": tftypes.NewValue(tftypes.String, "westeurope/somevalue"),
"location": tftypes.NewValue(tftypes.String, "westeurope"),
"name": tftypes.NewValue(tftypes.String, "somevalue"),
"id": tftypes.NewValue(tftypes.String, "foo/banana"),
"location": tftypes.NewValue(tftypes.String, "westeurope"),
"name": tftypes.NewValue(tftypes.String, "banana"),
"resource_group_name": tftypes.NewValue(tftypes.String, "foo"),
"instances": tftypes.NewValue(tftypes.Number, int64(5)),
},
),
Identity: teststep.Pointer(tftypes.NewValue(
tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"id": tftypes.String,
"location": tftypes.String,
"resource_group_name": tftypes.String,
"name": tftypes.String,
},
},
map[string]tftypes.Value{
"id": tftypes.NewValue(tftypes.String, "westeurope/somevalue"),
"location": tftypes.NewValue(tftypes.String, "westeurope/somevalue"),
"resource_group_name": tftypes.NewValue(tftypes.String, "foo"),
"name": tftypes.NewValue(tftypes.String, "banana"),
},
)),
},
Expand All @@ -104,6 +116,8 @@ func examplecloudResource() testprovider.Resource {
ComputedStringAttribute("id"),
RequiredStringAttribute("location"),
RequiredStringAttribute("name"),
RequiredStringAttribute("resource_group_name"),
OptionalNumberAttribute("instances"),
},
},
},
Expand All @@ -113,12 +127,12 @@ func examplecloudResource() testprovider.Resource {
Version: 1,
IdentityAttributes: []*tfprotov6.ResourceIdentitySchemaAttribute{
{
Name: "id",
Name: "resource_group_name",
Type: tftypes.String,
RequiredForImport: true,
},
{
Name: "location",
Name: "name",
Type: tftypes.String,
RequiredForImport: true,
},
Expand Down
Loading