How to use check method of main Package

Best Rod code snippet using main.check

resource_aws_route53_record_test.go

Source:resource_aws_route53_record_test.go Github

copy

Full Screen

...669const testAccRoute53FailoverCNAMERecord = `670resource "aws_route53_zone" "main" {671 name = "notexample.com"672}673resource "aws_route53_health_check" "foo" {674 fqdn = "dev.notexample.com"675 port = 80676 type = "HTTP"677 resource_path = "/"678 failure_threshold = "2"679 request_interval = "30"680 tags = {681 Name = "tf-test-health-check"682 }683}684resource "aws_route53_record" "www-primary" {685 zone_id = "${aws_route53_zone.main.zone_id}"686 name = "www"687 type = "CNAME"688 ttl = "5"689 failover_routing_policy {690 type = "PRIMARY"691 }692 health_check_id = "${aws_route53_health_check.foo.id}"693 set_identifier = "www-primary"694 records = ["primary.notexample.com"]695}696resource "aws_route53_record" "www-secondary" {697 zone_id = "${aws_route53_zone.main.zone_id}"698 name = "www"699 type = "CNAME"700 ttl = "5"701 failover_routing_policy {702 type = "SECONDARY"703 }704 set_identifier = "www-secondary"705 records = ["secondary.notexample.com"]706}...

Full Screen

Full Screen

resource_aws_api_gateway_usage_plan_test.go

Source:resource_aws_api_gateway_usage_plan_test.go Github

copy

Full Screen

1package aws2import (3 "fmt"4 "testing"5 "github.com/aws/aws-sdk-go/aws"6 "github.com/aws/aws-sdk-go/aws/awserr"7 "github.com/aws/aws-sdk-go/service/apigateway"8 "github.com/hashicorp/terraform/helper/acctest"9 "github.com/hashicorp/terraform/helper/resource"10 "github.com/hashicorp/terraform/terraform"11)12func TestAccAWSAPIGatewayUsagePlan_basic(t *testing.T) {13 var conf apigateway.UsagePlan14 name := acctest.RandString(10)15 updatedName := acctest.RandString(10)16 resource.Test(t, resource.TestCase{17 PreCheck: func() { testAccPreCheck(t) },18 Providers: testAccProviders,19 CheckDestroy: testAccCheckAWSAPIGatewayUsagePlanDestroy,20 Steps: []resource.TestStep{21 {22 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),23 Check: resource.ComposeTestCheckFunc(24 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),25 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),26 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "description", ""),27 ),28 },29 {30 Config: testAccAWSApiGatewayUsagePlanBasicUpdatedConfig(updatedName),31 Check: resource.ComposeTestCheckFunc(32 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", updatedName),33 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "description", ""),34 ),35 },36 {37 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),38 Check: resource.ComposeTestCheckFunc(39 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),40 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),41 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "description", ""),42 ),43 },44 },45 })46}47func TestAccAWSAPIGatewayUsagePlan_description(t *testing.T) {48 var conf apigateway.UsagePlan49 name := acctest.RandString(10)50 resource.Test(t, resource.TestCase{51 PreCheck: func() { testAccPreCheck(t) },52 Providers: testAccProviders,53 CheckDestroy: testAccCheckAWSAPIGatewayUsagePlanDestroy,54 Steps: []resource.TestStep{55 {56 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),57 Check: resource.ComposeTestCheckFunc(58 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),59 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "description", ""),60 ),61 },62 {63 Config: testAccAWSApiGatewayUsagePlanDescriptionConfig(name),64 Check: resource.ComposeTestCheckFunc(65 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),66 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "description", "This is a description"),67 ),68 },69 {70 Config: testAccAWSApiGatewayUsagePlanDescriptionUpdatedConfig(name),71 Check: resource.ComposeTestCheckFunc(72 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "description", "This is a new description"),73 ),74 },75 {76 Config: testAccAWSApiGatewayUsagePlanDescriptionConfig(name),77 Check: resource.ComposeTestCheckFunc(78 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),79 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "description", "This is a description"),80 ),81 },82 {83 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),84 Check: resource.ComposeTestCheckFunc(85 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),86 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "description", ""),87 ),88 },89 },90 })91}92func TestAccAWSAPIGatewayUsagePlan_productCode(t *testing.T) {93 var conf apigateway.UsagePlan94 name := acctest.RandString(10)95 resource.Test(t, resource.TestCase{96 PreCheck: func() { testAccPreCheck(t) },97 Providers: testAccProviders,98 CheckDestroy: testAccCheckAWSAPIGatewayUsagePlanDestroy,99 Steps: []resource.TestStep{100 {101 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),102 Check: resource.ComposeTestCheckFunc(103 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),104 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "product_code", ""),105 ),106 },107 {108 Config: testAccAWSApiGatewayUsagePlanProductCodeConfig(name),109 Check: resource.ComposeTestCheckFunc(110 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),111 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "product_code", "MYCODE"),112 ),113 },114 {115 Config: testAccAWSApiGatewayUsagePlanProductCodeUpdatedConfig(name),116 Check: resource.ComposeTestCheckFunc(117 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "product_code", "MYCODE2"),118 ),119 },120 {121 Config: testAccAWSApiGatewayUsagePlanProductCodeConfig(name),122 Check: resource.ComposeTestCheckFunc(123 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),124 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "product_code", "MYCODE"),125 ),126 },127 {128 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),129 Check: resource.ComposeTestCheckFunc(130 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),131 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "product_code", ""),132 ),133 },134 },135 })136}137func TestAccAWSAPIGatewayUsagePlan_throttling(t *testing.T) {138 var conf apigateway.UsagePlan139 name := acctest.RandString(10)140 resource.Test(t, resource.TestCase{141 PreCheck: func() { testAccPreCheck(t) },142 Providers: testAccProviders,143 CheckDestroy: testAccCheckAWSAPIGatewayUsagePlanDestroy,144 Steps: []resource.TestStep{145 {146 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),147 Check: resource.ComposeTestCheckFunc(148 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),149 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),150 resource.TestCheckNoResourceAttr("aws_api_gateway_usage_plan.main", "throttle_settings"),151 ),152 },153 {154 Config: testAccAWSApiGatewayUsagePlanThrottlingConfig(name),155 Check: resource.ComposeTestCheckFunc(156 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),157 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),158 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "throttle_settings.4173790118.burst_limit", "2"),159 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "throttle_settings.4173790118.rate_limit", "5"),160 ),161 },162 {163 Config: testAccAWSApiGatewayUsagePlanThrottlingModifiedConfig(name),164 Check: resource.ComposeTestCheckFunc(165 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),166 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),167 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "throttle_settings.1779463053.burst_limit", "3"),168 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "throttle_settings.1779463053.rate_limit", "6"),169 ),170 },171 {172 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),173 Check: resource.ComposeTestCheckFunc(174 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),175 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),176 resource.TestCheckNoResourceAttr("aws_api_gateway_usage_plan.main", "throttle_settings"),177 ),178 },179 },180 })181}182func TestAccAWSAPIGatewayUsagePlan_quota(t *testing.T) {183 var conf apigateway.UsagePlan184 name := acctest.RandString(10)185 resource.Test(t, resource.TestCase{186 PreCheck: func() { testAccPreCheck(t) },187 Providers: testAccProviders,188 CheckDestroy: testAccCheckAWSAPIGatewayUsagePlanDestroy,189 Steps: []resource.TestStep{190 {191 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),192 Check: resource.ComposeTestCheckFunc(193 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),194 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),195 resource.TestCheckNoResourceAttr("aws_api_gateway_usage_plan.main", "quota_settings"),196 ),197 },198 {199 Config: testAccAWSApiGatewayUsagePlanQuotaConfig(name),200 Check: resource.ComposeTestCheckFunc(201 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),202 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),203 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "quota_settings.1956747625.limit", "100"),204 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "quota_settings.1956747625.offset", "6"),205 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "quota_settings.1956747625.period", "WEEK"),206 ),207 },208 {209 Config: testAccAWSApiGatewayUsagePlanQuotaModifiedConfig(name),210 Check: resource.ComposeTestCheckFunc(211 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),212 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),213 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "quota_settings.3909168194.limit", "200"),214 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "quota_settings.3909168194.offset", "20"),215 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "quota_settings.3909168194.period", "MONTH"),216 ),217 },218 {219 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),220 Check: resource.ComposeTestCheckFunc(221 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),222 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),223 resource.TestCheckNoResourceAttr("aws_api_gateway_usage_plan.main", "quota_settings"),224 ),225 },226 },227 })228}229func TestAccAWSAPIGatewayUsagePlan_apiStages(t *testing.T) {230 var conf apigateway.UsagePlan231 name := acctest.RandString(10)232 resource.Test(t, resource.TestCase{233 PreCheck: func() { testAccPreCheck(t) },234 Providers: testAccProviders,235 CheckDestroy: testAccCheckAWSAPIGatewayUsagePlanDestroy,236 Steps: []resource.TestStep{237 // Create UsagePlan WITH Stages as the API calls are different238 // when creating or updating.239 {240 Config: testAccAWSApiGatewayUsagePlanApiStagesConfig(name),241 Check: resource.ComposeTestCheckFunc(242 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),243 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),244 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "api_stages.0.stage", "test"),245 ),246 },247 // Handle api stages removal248 {249 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),250 Check: resource.ComposeTestCheckFunc(251 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),252 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),253 resource.TestCheckNoResourceAttr("aws_api_gateway_usage_plan.main", "api_stages"),254 ),255 },256 // Handle api stages additions257 {258 Config: testAccAWSApiGatewayUsagePlanApiStagesConfig(name),259 Check: resource.ComposeTestCheckFunc(260 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),261 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),262 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "api_stages.0.stage", "test"),263 ),264 },265 // Handle api stages updates266 {267 Config: testAccAWSApiGatewayUsagePlanApiStagesModifiedConfig(name),268 Check: resource.ComposeTestCheckFunc(269 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),270 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),271 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "api_stages.0.stage", "foo"),272 ),273 },274 {275 Config: testAccAWSApiGatewayUsagePlanBasicConfig(name),276 Check: resource.ComposeTestCheckFunc(277 testAccCheckAWSAPIGatewayUsagePlanExists("aws_api_gateway_usage_plan.main", &conf),278 resource.TestCheckResourceAttr("aws_api_gateway_usage_plan.main", "name", name),279 resource.TestCheckNoResourceAttr("aws_api_gateway_usage_plan.main", "api_stages"),280 ),281 },282 },283 })284}285func testAccCheckAWSAPIGatewayUsagePlanExists(n string, res *apigateway.UsagePlan) resource.TestCheckFunc {286 return func(s *terraform.State) error {287 rs, ok := s.RootModule().Resources[n]288 if !ok {289 return fmt.Errorf("Not found: %s", n)290 }291 if rs.Primary.ID == "" {292 return fmt.Errorf("No API Gateway Usage Plan ID is set")293 }294 conn := testAccProvider.Meta().(*AWSClient).apigateway295 req := &apigateway.GetUsagePlanInput{296 UsagePlanId: aws.String(rs.Primary.ID),297 }298 up, err := conn.GetUsagePlan(req)299 if err != nil {300 return err301 }302 if *up.Id != rs.Primary.ID {303 return fmt.Errorf("APIGateway Usage Plan not found")304 }305 *res = *up306 return nil307 }308}309func testAccCheckAWSAPIGatewayUsagePlanDestroy(s *terraform.State) error {310 conn := testAccProvider.Meta().(*AWSClient).apigateway311 for _, rs := range s.RootModule().Resources {312 if rs.Type != "aws_api_gateway_usage_plan" {313 continue314 }315 req := &apigateway.GetUsagePlanInput{316 UsagePlanId: aws.String(s.RootModule().Resources["aws_api_gateway_rest_api.test"].Primary.ID),317 }318 describe, err := conn.GetUsagePlan(req)319 if err == nil {320 if describe.Id != nil && *describe.Id == rs.Primary.ID {321 return fmt.Errorf("API Gateway Usage Plan still exists")322 }323 }324 aws2err, ok := err.(awserr.Error)325 if !ok {326 return err327 }328 if aws2err.Code() != "NotFoundException" {329 return err330 }331 return nil332 }333 return nil334}335const testAccAWSAPIGatewayUsagePlanConfig = `336resource "aws_api_gateway_rest_api" "test" {337 name = "test"338}339resource "aws_api_gateway_resource" "test" {340 rest_api_id = "${aws_api_gateway_rest_api.test.id}"341 parent_id = "${aws_api_gateway_rest_api.test.root_resource_id}"342 path_part = "test"343}344resource "aws_api_gateway_method" "test" {345 rest_api_id = "${aws_api_gateway_rest_api.test.id}"346 resource_id = "${aws_api_gateway_resource.test.id}"347 http_method = "GET"348 authorization = "NONE"349}350resource "aws_api_gateway_method_response" "error" {351 rest_api_id = "${aws_api_gateway_rest_api.test.id}"352 resource_id = "${aws_api_gateway_resource.test.id}"353 http_method = "${aws_api_gateway_method.test.http_method}"354 status_code = "400"355}356resource "aws_api_gateway_integration" "test" {357 rest_api_id = "${aws_api_gateway_rest_api.test.id}"358 resource_id = "${aws_api_gateway_resource.test.id}"359 http_method = "${aws_api_gateway_method.test.http_method}"360 type = "HTTP"361 uri = "https://www.google.de"362 integration_http_method = "GET"363}364resource "aws_api_gateway_integration_response" "test" {365 rest_api_id = "${aws_api_gateway_rest_api.test.id}"366 resource_id = "${aws_api_gateway_resource.test.id}"367 http_method = "${aws_api_gateway_integration.test.http_method}"368 status_code = "${aws_api_gateway_method_response.error.status_code}"369}370resource "aws_api_gateway_deployment" "test" {371 depends_on = ["aws_api_gateway_integration.test"]372 rest_api_id = "${aws_api_gateway_rest_api.test.id}"373 stage_name = "test"374 description = "This is a test"375 variables = {376 "a" = "2"377 }378}379resource "aws_api_gateway_deployment" "foo" {380 depends_on = ["aws_api_gateway_integration.test"]381 rest_api_id = "${aws_api_gateway_rest_api.test.id}"382 stage_name = "foo"383 description = "This is a prod stage"384}385`386func testAccAWSApiGatewayUsagePlanBasicConfig(rName string) string {387 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`388resource "aws_api_gateway_usage_plan" "main" {389 name = "%s"390}391`, rName)392}393func testAccAWSApiGatewayUsagePlanDescriptionConfig(rName string) string {394 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`395resource "aws_api_gateway_usage_plan" "main" {396 name = "%s"397 description = "This is a description"398}399`, rName)400}401func testAccAWSApiGatewayUsagePlanDescriptionUpdatedConfig(rName string) string {402 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`403resource "aws_api_gateway_usage_plan" "main" {404 name = "%s"405 description = "This is a new description"406}407`, rName)408}409func testAccAWSApiGatewayUsagePlanProductCodeConfig(rName string) string {410 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`411resource "aws_api_gateway_usage_plan" "main" {412 name = "%s"413 product_code = "MYCODE"414}415`, rName)416}417func testAccAWSApiGatewayUsagePlanProductCodeUpdatedConfig(rName string) string {418 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`419resource "aws_api_gateway_usage_plan" "main" {420 name = "%s"421 product_code = "MYCODE2"422}423`, rName)424}425func testAccAWSApiGatewayUsagePlanBasicUpdatedConfig(rName string) string {426 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`427resource "aws_api_gateway_usage_plan" "main" {428 name = "%s"429}430`, rName)431}432func testAccAWSApiGatewayUsagePlanThrottlingConfig(rName string) string {433 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`434resource "aws_api_gateway_usage_plan" "main" {435 name = "%s"436 throttle_settings {437 burst_limit = 2438 rate_limit = 5439 }440}441`, rName)442}443func testAccAWSApiGatewayUsagePlanThrottlingModifiedConfig(rName string) string {444 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`445resource "aws_api_gateway_usage_plan" "main" {446 name = "%s"447 throttle_settings {448 burst_limit = 3449 rate_limit = 6450 }451}452`, rName)453}454func testAccAWSApiGatewayUsagePlanQuotaConfig(rName string) string {455 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`456resource "aws_api_gateway_usage_plan" "main" {457 name = "%s"458 quota_settings {459 limit = 100460 offset = 6461 period = "WEEK"462 }463}464`, rName)465}466func testAccAWSApiGatewayUsagePlanQuotaModifiedConfig(rName string) string {467 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`468resource "aws_api_gateway_usage_plan" "main" {469 name = "%s"470 quota_settings {471 limit = 200472 offset = 20473 period = "MONTH"474 }475}476`, rName)477}478func testAccAWSApiGatewayUsagePlanApiStagesConfig(rName string) string {479 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`480resource "aws_api_gateway_usage_plan" "main" {481 name = "%s"482 api_stages {483 api_id = "${aws_api_gateway_rest_api.test.id}"484 stage = "${aws_api_gateway_deployment.test.stage_name}"485 }486}487`, rName)488}489func testAccAWSApiGatewayUsagePlanApiStagesModifiedConfig(rName string) string {490 return fmt.Sprintf(testAccAWSAPIGatewayUsagePlanConfig+`491resource "aws_api_gateway_usage_plan" "main" {492 name = "%s"493 api_stages {494 api_id = "${aws_api_gateway_rest_api.test.id}"495 stage = "${aws_api_gateway_deployment.foo.stage_name}"496 }497}498`, rName)499}...

Full Screen

Full Screen

resource_aws_cognito_identity_pool_test.go

Source:resource_aws_cognito_identity_pool_test.go Github

copy

Full Screen

...150 testAccCheckAWSCognitoIdentityPoolExists("aws_cognito_identity_pool.main"),151 resource.TestCheckResourceAttr("aws_cognito_identity_pool.main", "identity_pool_name", fmt.Sprintf("identity pool %s", name)),152 resource.TestCheckResourceAttr("aws_cognito_identity_pool.main", "cognito_identity_providers.66456389.client_id", "7lhlkkfbfb4q5kpp90urffao"),153 resource.TestCheckResourceAttr("aws_cognito_identity_pool.main", "cognito_identity_providers.66456389.provider_name", "cognito-idp.us-east-1.amazonaws.com/us-east-1_Zr231apJu"),154 resource.TestCheckResourceAttr("aws_cognito_identity_pool.main", "cognito_identity_providers.66456389.server_side_token_check", "false"),155 resource.TestCheckResourceAttr("aws_cognito_identity_pool.main", "cognito_identity_providers.3571192419.client_id", "7lhlkkfbfb4q5kpp90urffao"),156 resource.TestCheckResourceAttr("aws_cognito_identity_pool.main", "cognito_identity_providers.3571192419.provider_name", "cognito-idp.us-east-1.amazonaws.com/us-east-1_Ab129faBb"),157 resource.TestCheckResourceAttr("aws_cognito_identity_pool.main", "cognito_identity_providers.3571192419.server_side_token_check", "false"),158 ),159 },160 {161 Config: testAccAWSCognitoIdentityPoolConfig_cognitoIdentityProvidersModified(name),162 Check: resource.ComposeAggregateTestCheckFunc(163 testAccCheckAWSCognitoIdentityPoolExists("aws_cognito_identity_pool.main"),164 resource.TestCheckResourceAttr("aws_cognito_identity_pool.main", "identity_pool_name", fmt.Sprintf("identity pool %s", name)),165 resource.TestCheckResourceAttr("aws_cognito_identity_pool.main", "cognito_identity_providers.3661724441.client_id", "6lhlkkfbfb4q5kpp90urffae"),166 resource.TestCheckResourceAttr("aws_cognito_identity_pool.main", "cognito_identity_providers.3661724441.provider_name", "cognito-idp.us-east-1.amazonaws.com/us-east-1_Zr231apJu"),167 resource.TestCheckResourceAttr("aws_cognito_identity_pool.main", "cognito_identity_providers.3661724441.server_side_token_check", "false"),168 ),169 },170 {171 Config: testAccAWSCognitoIdentityPoolConfig_basic(name),172 Check: resource.ComposeAggregateTestCheckFunc(173 testAccCheckAWSCognitoIdentityPoolExists("aws_cognito_identity_pool.main"),174 resource.TestCheckResourceAttr("aws_cognito_identity_pool.main", "identity_pool_name", fmt.Sprintf("identity pool %s", name)),175 ),176 },177 },178 })179}180func testAccCheckAWSCognitoIdentityPoolExists(n string) resource.TestCheckFunc {181 return func(s *terraform.State) error {182 rs, ok := s.RootModule().Resources[n]183 if !ok {184 return fmt.Errorf("Not found: %s", n)185 }186 if rs.Primary.ID == "" {187 return errors.New("No Cognito Identity Pool ID is set")188 }189 conn := testAccProvider.Meta().(*AWSClient).cognitoconn190 _, err := conn.DescribeIdentityPool(&cognitoidentity.DescribeIdentityPoolInput{191 IdentityPoolId: aws.String(rs.Primary.ID),192 })193 if err != nil {194 return err195 }196 return nil197 }198}199func testAccCheckAWSCognitoIdentityPoolDestroy(s *terraform.State) error {200 conn := testAccProvider.Meta().(*AWSClient).cognitoconn201 for _, rs := range s.RootModule().Resources {202 if rs.Type != "aws_cognito_identity_pool" {203 continue204 }205 _, err := conn.DescribeIdentityPool(&cognitoidentity.DescribeIdentityPoolInput{206 IdentityPoolId: aws.String(rs.Primary.ID),207 })208 if err != nil {209 if wserr, ok := err.(awserr.Error); ok && wserr.Code() == "ResourceNotFoundException" {210 return nil211 }212 return err213 }214 }215 return nil216}217func testAccAWSCognitoIdentityPoolConfig_basic(name string) string {218 return fmt.Sprintf(`219resource "aws_cognito_identity_pool" "main" {220 identity_pool_name = "identity pool %s"221 allow_unauthenticated_identities = false222 developer_provider_name = "my.developer"223}224`, name)225}226func testAccAWSCognitoIdentityPoolConfig_supportedLoginProviders(name string) string {227 return fmt.Sprintf(`228resource "aws_cognito_identity_pool" "main" {229 identity_pool_name = "identity pool %s"230 allow_unauthenticated_identities = false231 supported_login_providers {232 "graph.facebook.com" = "7346241598935555"233 }234}235`, name)236}237func testAccAWSCognitoIdentityPoolConfig_supportedLoginProvidersModified(name string) string {238 return fmt.Sprintf(`239resource "aws_cognito_identity_pool" "main" {240 identity_pool_name = "identity pool %s"241 allow_unauthenticated_identities = false242 supported_login_providers {243 "graph.facebook.com" = "7346241598935552"244 "accounts.google.com" = "123456789012.apps.googleusercontent.com"245 }246}247`, name)248}249func testAccAWSCognitoIdentityPoolConfig_openidConnectProviderArns(name string) string {250 return fmt.Sprintf(`251resource "aws_cognito_identity_pool" "main" {252 identity_pool_name = "identity pool %s"253 allow_unauthenticated_identities = false254 openid_connect_provider_arns = ["arn:aws:iam::123456789012:oidc-provider/server.example.com"]255}256`, name)257}258func testAccAWSCognitoIdentityPoolConfig_openidConnectProviderArnsModified(name string) string {259 return fmt.Sprintf(`260resource "aws_cognito_identity_pool" "main" {261 identity_pool_name = "identity pool %s"262 allow_unauthenticated_identities = false263 openid_connect_provider_arns = ["arn:aws:iam::123456789012:oidc-provider/foo.example.com", "arn:aws:iam::123456789012:oidc-provider/bar.example.com"]264}265`, name)266}267func testAccAWSCognitoIdentityPoolConfig_samlProviderArns(name string) string {268 return fmt.Sprintf(`269resource "aws_iam_saml_provider" "default" {270 name = "myprovider-%s"271 saml_metadata_document = "${file("./test-fixtures/saml-metadata.xml")}"272}273resource "aws_cognito_identity_pool" "main" {274 identity_pool_name = "identity pool %s"275 allow_unauthenticated_identities = false276 saml_provider_arns = ["${aws_iam_saml_provider.default.arn}"]277}278`, name, name)279}280func testAccAWSCognitoIdentityPoolConfig_samlProviderArnsModified(name string) string {281 return fmt.Sprintf(`282resource "aws_iam_saml_provider" "default" {283 name = "default-%s"284 saml_metadata_document = "${file("./test-fixtures/saml-metadata.xml")}"285}286resource "aws_iam_saml_provider" "secondary" {287 name = "secondary-%s"288 saml_metadata_document = "${file("./test-fixtures/saml-metadata.xml")}"289}290resource "aws_cognito_identity_pool" "main" {291 identity_pool_name = "identity pool %s"292 allow_unauthenticated_identities = false293 saml_provider_arns = ["${aws_iam_saml_provider.secondary.arn}"]294}295`, name, name, name)296}297func testAccAWSCognitoIdentityPoolConfig_cognitoIdentityProviders(name string) string {298 return fmt.Sprintf(`299resource "aws_cognito_identity_pool" "main" {300 identity_pool_name = "identity pool %s"301 allow_unauthenticated_identities = false302 cognito_identity_providers {303 client_id = "7lhlkkfbfb4q5kpp90urffao"304 provider_name = "cognito-idp.us-east-1.amazonaws.com/us-east-1_Ab129faBb"305 server_side_token_check = false306 }307 cognito_identity_providers {308 client_id = "7lhlkkfbfb4q5kpp90urffao"309 provider_name = "cognito-idp.us-east-1.amazonaws.com/us-east-1_Zr231apJu"310 server_side_token_check = false311 }312}313`, name)314}315func testAccAWSCognitoIdentityPoolConfig_cognitoIdentityProvidersModified(name string) string {316 return fmt.Sprintf(`317resource "aws_cognito_identity_pool" "main" {318 identity_pool_name = "identity pool %s"319 allow_unauthenticated_identities = false320 cognito_identity_providers {321 client_id = "6lhlkkfbfb4q5kpp90urffae"322 provider_name = "cognito-idp.us-east-1.amazonaws.com/us-east-1_Zr231apJu"323 server_side_token_check = false324 }325}326`, name)327}...

Full Screen

Full Screen

check

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Enter 10 numbers to check whether they are even or odd")4 fmt.Scanln(&a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9, &a10)5 EvenOrOdd(a1)6 EvenOrOdd(a2)7 EvenOrOdd(a3)8 EvenOrOdd(a4)9 EvenOrOdd(a5)10 EvenOrOdd(a6)11 EvenOrOdd(a7)12 EvenOrOdd(a8)13 EvenOrOdd(a9)14 EvenOrOdd(a10)15}16import (17func EvenOrOdd(a int) {18 if a%2 == 0 {19 fmt.Println(a, "is even")20 } else {21 fmt.Println(a, "is odd")22 }23}24import (25func main() {26 fmt.Println("Enter 10 numbers to check whether they are even or odd")27 fmt.Scanln(&a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9, &a10)28 EvenOrOdd(a1)29 EvenOrOdd(a2)30 EvenOrOdd(a3)31 EvenOrOdd(a4)32 EvenOrOdd(a5)33 EvenOrOdd(a6)34 EvenOrOdd(a7)35 EvenOrOdd(a8)36 EvenOrOdd(a9)37 EvenOrOdd(a10)38}39import (40func EvenOrOdd(a int) {41 if a%2 == 0 {42 fmt.Println(a, "is even")43 } else {44 fmt.Println(a, "is odd")45 }

Full Screen

Full Screen

check

Using AI Code Generation

copy

Full Screen

1import "fmt"2func (m myInt) check() bool {3 if m % 2 == 0 {4 }5}6func main() {7 fmt.Println("Enter a number: ")8 fmt.Scan(&num)9 if num.check() {10 fmt.Println("Even")11 } else {12 fmt.Println("Odd")13 }14}15type Animal interface {16 Eat()17 Move()18 Speak()19}20import "fmt"21type Animal interface {22 Eat()23 Move()24 Speak()25}26type Cow struct {27}28func (c Cow) Eat() {29 fmt.Println(c.food)30}31func (c Cow) Move() {32 fmt.Println(c.locomotion)33}34func (c Cow) Speak() {35 fmt.Println(c.noise)36}37type Bird struct {38}39func (b Bird) Eat() {40 fmt.Println(b.food)41}42func (b Bird) Move() {43 fmt.Println(b.locomotion)44}45func (b Bird) Speak() {46 fmt.Println(b.noise)47}48type Snake struct {49}50func (s Snake) Eat() {51 fmt.Println(s.food)52}53func (s Snake) Move() {54 fmt.Println(s.locomotion)55}56func (s Snake) Speak() {57 fmt.Println(s.noise)58}59func main() {60 for {61 fmt.Println("Enter <name> <action> or X to exit")62 fmt.Scan(&name, &action)63 if name == "X" {64 }65 switch name {66 animal = Cow{name, "grass", "walk", "moo"}67 animal = Bird{name, "worms

Full Screen

Full Screen

check

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 ret = max(a, b)4 fmt.Printf( "Max value is : %d\n", ret )5}6func max(num1, num2 int) int {7 if (num1 > num2) {8 } else {9 }10}11import "fmt"12func main() {13 ret = min(a, b)14 fmt.Printf( "Min value is : %d\n", ret )15}16func min(num1, num2 int) int {17 if (num1 > num2) {18 } else {19 }20}21import "fmt"22func main() {23 ret = sum(a, b)24 fmt.Printf( "Sum value is : %d\n", ret )25}26func sum(num1, num2 int) int {27}28import "fmt"29func main() {30 ret = sub(a, b)31 fmt.Printf( "Sub value is : %d\n", ret )32}33func sub(num1, num2 int) int {34}35import "fmt"36func main() {

Full Screen

Full Screen

check

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello World")4 pkg1.Check()5}6import (7func main() {8 fmt.Println("Hello World")9 pkg1.Check()10}11import (12func main() {13 fmt.Println("Hello World")14 pkg1.Check()15}16import (17func main() {18 fmt.Println("Hello World")19 pkg1.Check()20}21import (22func main() {23 fmt.Println("Hello World")24 pkg1.Check()25}26import (27func main() {28 fmt.Println("Hello World")29 pkg1.Check()30}31import (32func main() {33 fmt.Println("Hello World")34 pkg1.Check()35}36import (37func main() {38 fmt.Println("Hello World")39 pkg1.Check()40}41import (42func main() {43 fmt.Println("Hello World")44 pkg1.Check()45}

Full Screen

Full Screen

check

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello, playground")4 test1.Check()5}6import "fmt"7func Check() {8 fmt.Println("Hello, playground")9}

Full Screen

Full Screen

check

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 test.Check()4 fmt.Println("Hello World")5}6import "fmt"7func Check() {8 fmt.Println("Hello World")9}10import "fmt"11func Check() {12 fmt.Println("Hello World")13}14import "fmt"15func Check1() {16 fmt.Println("Hello World 1")17}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful