當前位置: 首頁>>代碼示例>>Golang>>正文


Golang resource.TestCheckResourceAttr函數代碼示例

本文整理匯總了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"),
				),
			},
		},
	})
}
開發者ID:devendraPSL,項目名稱:terraform-api,代碼行數:29,代碼來源:resource_aws_route53_health_check_test.go

示例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$"),
					),
				),
			},
		},
	})
}
開發者ID:devendraPSL,項目名稱:terraform-api,代碼行數:35,代碼來源:resource_aws_lambda_event_source_mapping_test.go

示例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", ""),
				),
			},
		},
	})
}
開發者ID:devendraPSL,項目名稱:terraform-api,代碼行數:34,代碼來源:resource_heroku_app_test.go

示例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"),
				),
			},
		},
	})
}
開發者ID:devendraPSL,項目名稱:terraform-api,代碼行數:25,代碼來源:resource_dnsimple_record_test.go

示例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"),
				),
			},
		},
	})
}
開發者ID:devendraPSL,項目名稱:terraform-api,代碼行數:34,代碼來源:resource_aws_elasticache_cluster_test.go

示例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",
					),
				),
			},
		},
	})
}
開發者ID:devendraPSL,項目名稱:terraform-api,代碼行數:25,代碼來源:resource_aws_elb_test.go

示例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"),
				),
			},
		},
	})
}
開發者ID:devendraPSL,項目名稱:terraform-api,代碼行數:25,代碼來源:resource_dyn_record_test.go

示例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"),
				),
			},
		},
	})
}
開發者ID:devendraPSL,項目名稱:terraform-api,代碼行數:35,代碼來源:resource_heroku_addon_test.go

示例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"),
				),
			},
		},
	})
}
開發者ID:devendraPSL,項目名稱:terraform-api,代碼行數:28,代碼來源:resource_azure_dns_server_test.go

示例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"),
				),
			},
		},
	})
}
開發者ID:devendraPSL,項目名稱:terraform-api,代碼行數:34,代碼來源:resource_azure_hosted_service_test.go

示例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"),
				),
			},
		},
	})
}
開發者ID:devendraPSL,項目名稱:terraform-api,代碼行數:25,代碼來源:resource_heroku_addon_test.go

示例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"),
				),
			},
		},
	})
}
開發者ID:devendraPSL,項目名稱:terraform-api,代碼行數:28,代碼來源:resource_aws_db_security_group_test.go

示例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),
				),
			},
		},
	})
}
開發者ID:devendraPSL,項目名稱:terraform-api,代碼行數:60,代碼來源:resource_vsphere_virtual_machine_test.go

示例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"),
				),
			},
		},
	})
}
開發者ID:devendraPSL,項目名稱:terraform-api,代碼行數:25,代碼來源:resource_cloudstack_port_forward_test.go

示例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"),
				),
			},
		},
	})
}
開發者ID:devendraPSL,項目名稱:terraform-api,代碼行數:28,代碼來源:resource_aws_elb_test.go


注:本文中的github.com/xanzy/terraform-api/helper/resource.TestCheckResourceAttr函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。