本文整理汇总了Golang中github.com/xanzy/terraform-api/helper/resource.TestCheckResourceAttr函数的典型用法代码示例。如果您正苦于以下问题:Golang TestCheckResourceAttr函数的具体用法?Golang TestCheckResourceAttr怎么用?Golang TestCheckResourceAttr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TestCheckResourceAttr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestAccAWSRoute53HealthCheck_basic
func TestAccAWSRoute53HealthCheck_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRoute53HealthCheckDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccRoute53HealthCheckConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckRoute53HealthCheckExists("aws_route53_health_check.foo"),
resource.TestCheckResourceAttr(
"aws_route53_health_check.foo", "measure_latency", "true"),
resource.TestCheckResourceAttr(
"aws_route53_health_check.foo", "invert_healthcheck", "true"),
),
},
resource.TestStep{
Config: testAccRoute53HealthCheckConfigUpdate,
Check: resource.ComposeTestCheckFunc(
testAccCheckRoute53HealthCheckExists("aws_route53_health_check.foo"),
resource.TestCheckResourceAttr(
"aws_route53_health_check.foo", "failure_threshold", "5"),
resource.TestCheckResourceAttr(
"aws_route53_health_check.foo", "invert_healthcheck", "false"),
),
},
},
})
}
示例2: TestAccAWSLambdaEventSourceMapping_basic
func TestAccAWSLambdaEventSourceMapping_basic(t *testing.T) {
var conf lambda.EventSourceMappingConfiguration
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckLambdaEventSourceMappingDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSLambdaEventSourceMappingConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsLambdaEventSourceMappingExists("aws_lambda_event_source_mapping.lambda_event_source_mapping_test", &conf),
testAccCheckAWSLambdaEventSourceMappingAttributes(&conf),
),
},
resource.TestStep{
Config: testAccAWSLambdaEventSourceMappingConfigUpdate,
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsLambdaEventSourceMappingExists("aws_lambda_event_source_mapping.lambda_event_source_mapping_test", &conf),
resource.TestCheckResourceAttr("aws_lambda_event_source_mapping.lambda_event_source_mapping_test",
"batch_size",
strconv.Itoa(200)),
resource.TestCheckResourceAttr("aws_lambda_event_source_mapping.lambda_event_source_mapping_test",
"enabled",
strconv.FormatBool(false)),
resource.TestMatchResourceAttr(
"aws_lambda_event_source_mapping.lambda_event_source_mapping_test",
"function_arn",
regexp.MustCompile("example_lambda_name_update$"),
),
),
},
},
})
}
示例3: TestAccHerokuApp_NukeVars
func TestAccHerokuApp_NukeVars(t *testing.T) {
var app heroku.App
appName := fmt.Sprintf("tftest-%s", acctest.RandString(10))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckHerokuAppDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccCheckHerokuAppConfig_basic(appName),
Check: resource.ComposeTestCheckFunc(
testAccCheckHerokuAppExists("heroku_app.foobar", &app),
testAccCheckHerokuAppAttributes(&app, appName),
resource.TestCheckResourceAttr(
"heroku_app.foobar", "name", appName),
resource.TestCheckResourceAttr(
"heroku_app.foobar", "config_vars.0.FOO", "bar"),
),
},
resource.TestStep{
Config: testAccCheckHerokuAppConfig_no_vars(appName),
Check: resource.ComposeTestCheckFunc(
testAccCheckHerokuAppExists("heroku_app.foobar", &app),
testAccCheckHerokuAppAttributesNoVars(&app, appName),
resource.TestCheckResourceAttr(
"heroku_app.foobar", "name", appName),
resource.TestCheckResourceAttr(
"heroku_app.foobar", "config_vars.0.FOO", ""),
),
},
},
})
}
示例4: TestAccDNSimpleRecord_Basic
func TestAccDNSimpleRecord_Basic(t *testing.T) {
var record dnsimple.Record
domain := os.Getenv("DNSIMPLE_DOMAIN")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDNSimpleRecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: fmt.Sprintf(testAccCheckDNSimpleRecordConfig_basic, domain),
Check: resource.ComposeTestCheckFunc(
testAccCheckDNSimpleRecordExists("dnsimple_record.foobar", &record),
testAccCheckDNSimpleRecordAttributes(&record),
resource.TestCheckResourceAttr(
"dnsimple_record.foobar", "name", "terraform"),
resource.TestCheckResourceAttr(
"dnsimple_record.foobar", "domain", domain),
resource.TestCheckResourceAttr(
"dnsimple_record.foobar", "value", "192.168.0.10"),
),
},
},
})
}
示例5: TestAccAWSElasticacheCluster_decreasingCacheNodes
func TestAccAWSElasticacheCluster_decreasingCacheNodes(t *testing.T) {
var ec elasticache.CacheCluster
ri := genRandInt()
preConfig := fmt.Sprintf(testAccAWSElasticacheClusterConfigDecreasingNodes, ri, ri, ri)
postConfig := fmt.Sprintf(testAccAWSElasticacheClusterConfigDecreasingNodes_update, ri, ri, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSElasticacheClusterDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: preConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSElasticacheSecurityGroupExists("aws_elasticache_security_group.bar"),
testAccCheckAWSElasticacheClusterExists("aws_elasticache_cluster.bar", &ec),
resource.TestCheckResourceAttr(
"aws_elasticache_cluster.bar", "num_cache_nodes", "3"),
),
},
resource.TestStep{
Config: postConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSElasticacheSecurityGroupExists("aws_elasticache_security_group.bar"),
testAccCheckAWSElasticacheClusterExists("aws_elasticache_cluster.bar", &ec),
resource.TestCheckResourceAttr(
"aws_elasticache_cluster.bar", "num_cache_nodes", "1"),
),
},
},
})
}
示例6: TestAccAWSELB_SecurityGroups
func TestAccAWSELB_SecurityGroups(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSELBDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSELBConfig,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"aws_elb.bar", "security_groups.#", "0",
),
),
},
resource.TestStep{
Config: testAccAWSELBConfigSecurityGroups,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"aws_elb.bar", "security_groups.#", "1",
),
),
},
},
})
}
示例7: TestAccDynRecord_Basic
func TestAccDynRecord_Basic(t *testing.T) {
var record dynect.Record
zone := os.Getenv("DYN_ZONE")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckDynRecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: fmt.Sprintf(testAccCheckDynRecordConfig_basic, zone),
Check: resource.ComposeTestCheckFunc(
testAccCheckDynRecordExists("dyn_record.foobar", &record),
testAccCheckDynRecordAttributes(&record),
resource.TestCheckResourceAttr(
"dyn_record.foobar", "name", "terraform"),
resource.TestCheckResourceAttr(
"dyn_record.foobar", "zone", zone),
resource.TestCheckResourceAttr(
"dyn_record.foobar", "value", "192.168.0.10"),
),
},
},
})
}
示例8: TestAccHerokuAddon_noPlan
// GH-198
func TestAccHerokuAddon_noPlan(t *testing.T) {
var addon heroku.Addon
appName := fmt.Sprintf("tftest-%s", acctest.RandString(10))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckHerokuAddonDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccCheckHerokuAddonConfig_no_plan(appName),
Check: resource.ComposeTestCheckFunc(
testAccCheckHerokuAddonExists("heroku_addon.foobar", &addon),
testAccCheckHerokuAddonAttributes(&addon, "memcachier:dev"),
resource.TestCheckResourceAttr(
"heroku_addon.foobar", "app", appName),
resource.TestCheckResourceAttr(
"heroku_addon.foobar", "plan", "memcachier"),
),
},
resource.TestStep{
Config: testAccCheckHerokuAddonConfig_no_plan(appName),
Check: resource.ComposeTestCheckFunc(
testAccCheckHerokuAddonExists("heroku_addon.foobar", &addon),
testAccCheckHerokuAddonAttributes(&addon, "memcachier:dev"),
resource.TestCheckResourceAttr(
"heroku_addon.foobar", "app", appName),
resource.TestCheckResourceAttr(
"heroku_addon.foobar", "plan", "memcachier"),
),
},
},
})
}
示例9: TestAccAzureDnsServerUpdate
func TestAccAzureDnsServerUpdate(t *testing.T) {
name := "azure_dns_server.foo"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAzureDnsServerDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAzureDnsServerBasic,
Check: resource.ComposeTestCheckFunc(
testAccCheckAzureDnsServerExists(name),
resource.TestCheckResourceAttr(name, "name", "terraform-dns-server"),
resource.TestCheckResourceAttr(name, "dns_address", "8.8.8.8"),
),
},
resource.TestStep{
Config: testAccAzureDnsServerUpdate,
Check: resource.ComposeTestCheckFunc(
testAccCheckAzureDnsServerExists(name),
resource.TestCheckResourceAttr(name, "name", "terraform-dns-server"),
resource.TestCheckResourceAttr(name, "dns_address", "8.8.4.4"),
),
},
},
})
}
示例10: TestAccAzureHostedServiceUpdate
func TestAccAzureHostedServiceUpdate(t *testing.T) {
name := "azure_hosted_service.foo"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAzureHostedServiceDestroyed,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAzureHostedServiceBasic,
Check: resource.ComposeTestCheckFunc(
testAccCheckAzureHostedServiceExists(name),
resource.TestCheckResourceAttr(name, "name", "terraform-testing-service"),
resource.TestCheckResourceAttr(name, "location", "North Europe"),
resource.TestCheckResourceAttr(name, "ephemeral_contents", "false"),
resource.TestCheckResourceAttr(name, "description", "very discriptive"),
resource.TestCheckResourceAttr(name, "label", "very identifiable"),
),
},
resource.TestStep{
Config: testAccAzureHostedServiceUpdate,
Check: resource.ComposeTestCheckFunc(
testAccCheckAzureHostedServiceExists(name),
resource.TestCheckResourceAttr(name, "name", "terraform-testing-service"),
resource.TestCheckResourceAttr(name, "location", "North Europe"),
resource.TestCheckResourceAttr(name, "ephemeral_contents", "true"),
resource.TestCheckResourceAttr(name, "description", "very discriptive"),
resource.TestCheckResourceAttr(name, "label", "very identifiable"),
),
},
},
})
}
示例11: TestAccHerokuAddon_Basic
func TestAccHerokuAddon_Basic(t *testing.T) {
var addon heroku.Addon
appName := fmt.Sprintf("tftest-%s", acctest.RandString(10))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckHerokuAddonDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccCheckHerokuAddonConfig_basic(appName),
Check: resource.ComposeTestCheckFunc(
testAccCheckHerokuAddonExists("heroku_addon.foobar", &addon),
testAccCheckHerokuAddonAttributes(&addon, "deployhooks:http"),
resource.TestCheckResourceAttr(
"heroku_addon.foobar", "config.0.url", "http://google.com"),
resource.TestCheckResourceAttr(
"heroku_addon.foobar", "app", appName),
resource.TestCheckResourceAttr(
"heroku_addon.foobar", "plan", "deployhooks:http"),
),
},
},
})
}
示例12: TestAccAWSDBSecurityGroup_basic
func TestAccAWSDBSecurityGroup_basic(t *testing.T) {
var v rds.DBSecurityGroup
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSDBSecurityGroupDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSDBSecurityGroupConfig,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDBSecurityGroupExists("aws_db_security_group.bar", &v),
testAccCheckAWSDBSecurityGroupAttributes(&v),
resource.TestCheckResourceAttr(
"aws_db_security_group.bar", "name", "secgroup-terraform"),
resource.TestCheckResourceAttr(
"aws_db_security_group.bar", "description", "just cuz"),
resource.TestCheckResourceAttr(
"aws_db_security_group.bar", "ingress.3363517775.cidr", "10.0.0.1/24"),
resource.TestCheckResourceAttr(
"aws_db_security_group.bar", "ingress.#", "1"),
resource.TestCheckResourceAttr(
"aws_db_security_group.bar", "tags.#", "1"),
),
},
},
})
}
示例13: TestAccVSphereVirtualMachine_custom_configs
func TestAccVSphereVirtualMachine_custom_configs(t *testing.T) {
var vm virtualMachine
var locationOpt string
var datastoreOpt string
if v := os.Getenv("VSPHERE_DATACENTER"); v != "" {
locationOpt += fmt.Sprintf(" datacenter = \"%s\"\n", v)
}
if v := os.Getenv("VSPHERE_CLUSTER"); v != "" {
locationOpt += fmt.Sprintf(" cluster = \"%s\"\n", v)
}
if v := os.Getenv("VSPHERE_RESOURCE_POOL"); v != "" {
locationOpt += fmt.Sprintf(" resource_pool = \"%s\"\n", v)
}
if v := os.Getenv("VSPHERE_DATASTORE"); v != "" {
datastoreOpt = fmt.Sprintf(" datastore = \"%s\"\n", v)
}
template := os.Getenv("VSPHERE_TEMPLATE")
label := os.Getenv("VSPHERE_NETWORK_LABEL_DHCP")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckVSphereVirtualMachineDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: fmt.Sprintf(
testAccCheckVSphereVirtualMachineConfig_custom_configs,
locationOpt,
label,
datastoreOpt,
template,
),
Check: resource.ComposeTestCheckFunc(
testAccCheckVSphereVirtualMachineExistsHasCustomConfig("vsphere_virtual_machine.car", &vm),
resource.TestCheckResourceAttr(
"vsphere_virtual_machine.car", "name", "terraform-test-custom"),
resource.TestCheckResourceAttr(
"vsphere_virtual_machine.car", "vcpu", "2"),
resource.TestCheckResourceAttr(
"vsphere_virtual_machine.car", "memory", "4096"),
resource.TestCheckResourceAttr(
"vsphere_virtual_machine.car", "disk.#", "1"),
resource.TestCheckResourceAttr(
"vsphere_virtual_machine.car", "disk.0.template", template),
resource.TestCheckResourceAttr(
"vsphere_virtual_machine.car", "network_interface.#", "1"),
resource.TestCheckResourceAttr(
"vsphere_virtual_machine.car", "custom_configuration_parameters.foo", "bar"),
resource.TestCheckResourceAttr(
"vsphere_virtual_machine.car", "custom_configuration_parameters.car", "ferrari"),
resource.TestCheckResourceAttr(
"vsphere_virtual_machine.car", "custom_configuration_parameters.num", "42"),
resource.TestCheckResourceAttr(
"vsphere_virtual_machine.car", "network_interface.0.label", label),
),
},
},
})
}
示例14: TestAccCloudStackPortForward_basic
func TestAccCloudStackPortForward_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCloudStackPortForwardDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccCloudStackPortForward_basic,
Check: resource.ComposeTestCheckFunc(
testAccCheckCloudStackPortForwardsExist("cloudstack_port_forward.foo"),
resource.TestCheckResourceAttr(
"cloudstack_port_forward.foo", "ipaddress", CLOUDSTACK_PUBLIC_IPADDRESS),
resource.TestCheckResourceAttr(
"cloudstack_port_forward.foo", "forward.952396423.protocol", "tcp"),
resource.TestCheckResourceAttr(
"cloudstack_port_forward.foo", "forward.952396423.private_port", "443"),
resource.TestCheckResourceAttr(
"cloudstack_port_forward.foo", "forward.952396423.public_port", "8443"),
resource.TestCheckResourceAttr(
"cloudstack_port_forward.foo", "forward.952396423.virtual_machine", "terraform-test"),
),
},
},
})
}
示例15: TestAccAWSELB_HealthCheck
func TestAccAWSELB_HealthCheck(t *testing.T) {
var conf elb.LoadBalancerDescription
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSELBDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSELBConfigHealthCheck,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSELBExists("aws_elb.bar", &conf),
testAccCheckAWSELBAttributesHealthCheck(&conf),
resource.TestCheckResourceAttr(
"aws_elb.bar", "health_check.3484319807.healthy_threshold", "5"),
resource.TestCheckResourceAttr(
"aws_elb.bar", "health_check.3484319807.unhealthy_threshold", "5"),
resource.TestCheckResourceAttr(
"aws_elb.bar", "health_check.3484319807.target", "HTTP:8000/"),
resource.TestCheckResourceAttr(
"aws_elb.bar", "health_check.3484319807.timeout", "30"),
resource.TestCheckResourceAttr(
"aws_elb.bar", "health_check.3484319807.interval", "60"),
),
},
},
})
}