core: update various context apply tests for schema/fixtures
Most of these changes are just adding schema to describe the expectations of the existing test fixtures. However, some of them require the fixtures themselves to be changed due to changing assumptions in the language.
This commit is contained in:
parent
8774c857f6
commit
1caffba0e6
|
@ -2012,6 +2012,20 @@ func TestContext2Apply_compute(t *testing.T) {
|
||||||
p := testProvider("aws")
|
p := testProvider("aws")
|
||||||
p.ApplyFn = testApplyFn
|
p.ApplyFn = testApplyFn
|
||||||
p.DiffFn = testDiffFn
|
p.DiffFn = testDiffFn
|
||||||
|
p.GetSchemaReturn = &ProviderSchema{
|
||||||
|
ResourceTypes: map[string]*configschema.Block{
|
||||||
|
"aws_instance": {
|
||||||
|
Attributes: map[string]*configschema.Attribute{
|
||||||
|
"num": {Type: cty.String, Optional: true},
|
||||||
|
"compute": {Type: cty.String, Optional: true},
|
||||||
|
"compute_value": {Type: cty.String, Optional: true},
|
||||||
|
"foo": {Type: cty.String, Optional: true},
|
||||||
|
"dynamical": {Type: cty.String, Computed: true},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
ctx := testContext2(t, &ContextOpts{
|
ctx := testContext2(t, &ContextOpts{
|
||||||
Config: m,
|
Config: m,
|
||||||
ProviderResolver: ResourceProviderResolverFixed(
|
ProviderResolver: ResourceProviderResolverFixed(
|
||||||
|
@ -3527,6 +3541,28 @@ func TestContext2Apply_multiVarComprehensive(t *testing.T) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.GetSchemaReturn = &ProviderSchema{
|
||||||
|
ResourceTypes: map[string]*configschema.Block{
|
||||||
|
"test_thing": {
|
||||||
|
Attributes: map[string]*configschema.Attribute{
|
||||||
|
"source_id": {Type: cty.String, Optional: true},
|
||||||
|
"source_name": {Type: cty.String, Optional: true},
|
||||||
|
"first_source_id": {Type: cty.String, Optional: true},
|
||||||
|
"first_source_name": {Type: cty.String, Optional: true},
|
||||||
|
"source_ids": {Type: cty.List(cty.String), Optional: true},
|
||||||
|
"source_names": {Type: cty.List(cty.String), Optional: true},
|
||||||
|
"source_ids_from_func": {Type: cty.List(cty.String), Optional: true},
|
||||||
|
"source_names_from_func": {Type: cty.List(cty.String), Optional: true},
|
||||||
|
"source_ids_wrapped": {Type: cty.List(cty.String), Optional: true},
|
||||||
|
"source_names_wrapped": {Type: cty.List(cty.String), Optional: true},
|
||||||
|
|
||||||
|
"id": {Type: cty.String, Computed: true},
|
||||||
|
"name": {Type: cty.String, Computed: true},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
// First, apply with a count of 3
|
// First, apply with a count of 3
|
||||||
ctx := testContext2(t, &ContextOpts{
|
ctx := testContext2(t, &ContextOpts{
|
||||||
Config: m,
|
Config: m,
|
||||||
|
@ -4180,10 +4216,18 @@ func TestContext2Apply_providerConfigureDisabled(t *testing.T) {
|
||||||
|
|
||||||
func TestContext2Apply_provisionerModule(t *testing.T) {
|
func TestContext2Apply_provisionerModule(t *testing.T) {
|
||||||
m := testModule(t, "apply-provisioner-module")
|
m := testModule(t, "apply-provisioner-module")
|
||||||
|
|
||||||
p := testProvider("aws")
|
p := testProvider("aws")
|
||||||
pr := testProvisioner()
|
|
||||||
p.ApplyFn = testApplyFn
|
p.ApplyFn = testApplyFn
|
||||||
p.DiffFn = testDiffFn
|
p.DiffFn = testDiffFn
|
||||||
|
|
||||||
|
pr := testProvisioner()
|
||||||
|
pr.GetConfigSchemaReturnSchema = &configschema.Block{
|
||||||
|
Attributes: map[string]*configschema.Attribute{
|
||||||
|
"foo": {Type: cty.String, Optional: true},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
ctx := testContext2(t, &ContextOpts{
|
ctx := testContext2(t, &ContextOpts{
|
||||||
Config: m,
|
Config: m,
|
||||||
ProviderResolver: ResourceProviderResolverFixed(
|
ProviderResolver: ResourceProviderResolverFixed(
|
||||||
|
|
|
@ -7,5 +7,5 @@ resource "aws_instance" "foo" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_instance" "bar" {
|
resource "aws_instance" "bar" {
|
||||||
foo = "${aws_instance.foo.count}"
|
foo = length(aws_instance.foo)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ resource "test_thing" "multi_count_var" {
|
||||||
|
|
||||||
resource "test_thing" "multi_count_derived" {
|
resource "test_thing" "multi_count_derived" {
|
||||||
# Can use the source to get the count
|
# Can use the source to get the count
|
||||||
count = "${test_thing.source.count}"
|
count = "${length(test_thing.source)}"
|
||||||
|
|
||||||
source_id = "${test_thing.source.*.id[count.index]}"
|
source_id = "${test_thing.source.*.id[count.index]}"
|
||||||
source_name = "${test_thing.source.*.name[count.index]}"
|
source_name = "${test_thing.source.*.name[count.index]}"
|
||||||
|
@ -52,7 +52,7 @@ resource "test_thing" "whole_splat" {
|
||||||
module "child" {
|
module "child" {
|
||||||
source = "./child"
|
source = "./child"
|
||||||
|
|
||||||
count = "${var.num}"
|
num = "${var.num}"
|
||||||
source_ids = "${test_thing.source.*.id}"
|
source_ids = "${test_thing.source.*.id}"
|
||||||
source_names = "${test_thing.source.*.name}"
|
source_names = "${test_thing.source.*.name}"
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,5 @@ resource "aws_instance" "foo" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_instance" "bar" {
|
resource "aws_instance" "bar" {
|
||||||
foo = "${aws_instance.foo.count}"
|
foo = length(aws_instance.foo)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue