|
| 1 | +// Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. |
| 2 | +// Licensed under the Mozilla Public License v2.0 |
| 3 | + |
| 4 | +package integrationtest |
| 5 | + |
| 6 | +import ( |
| 7 | + "fmt" |
| 8 | + "testing" |
| 9 | + |
| 10 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" |
| 11 | + |
| 12 | + "github.com/oracle/terraform-provider-oci/httpreplay" |
| 13 | + "github.com/oracle/terraform-provider-oci/internal/acctest" |
| 14 | + |
| 15 | + "github.com/oracle/terraform-provider-oci/internal/utils" |
| 16 | +) |
| 17 | + |
| 18 | +var ( |
| 19 | + RecoveryprotectedDatabaseFetchConfigurationSingularDataSourceRepresentation = map[string]interface{}{ |
| 20 | + "protected_database_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_recovery_protected_database.test_protected_database.id}`}, |
| 21 | + "base64_encode_content": acctest.Representation{RepType: acctest.Optional, Create: `false`}, |
| 22 | + "configuration_type": acctest.Representation{RepType: acctest.Optional, Create: `ALL`}, |
| 23 | + } |
| 24 | + |
| 25 | + RecoveryProtectedDatabaseFetchConfigurationResourceConfig = RecoveryProtectedDatabaseRequiredOnlyResource |
| 26 | +) |
| 27 | + |
| 28 | +// issue-routing-tag: recovery/default |
| 29 | +func TestRecoveryProtectedDatabaseFetchConfigurationResource_basic(t *testing.T) { |
| 30 | + httpreplay.SetScenario("TestRecoveryProtectedDatabaseFetchConfigurationResource_basic") |
| 31 | + defer httpreplay.SaveScenario() |
| 32 | + |
| 33 | + config := acctest.ProviderTestConfig() |
| 34 | + |
| 35 | + compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid") |
| 36 | + compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId) |
| 37 | + |
| 38 | + singularDatasourceName := "data.oci_recovery_protected_database_fetch_configuration.test_protected_database_fetch_configuration" |
| 39 | + |
| 40 | + acctest.SaveConfigContent("", "", "", t) |
| 41 | + |
| 42 | + acctest.ResourceTest(t, nil, []resource.TestStep{ |
| 43 | + // verify singular datasource |
| 44 | + { |
| 45 | + Config: config + |
| 46 | + acctest.GenerateDataSourceFromRepresentationMap("oci_recovery_protected_database_fetch_configuration", "test_protected_database_fetch_configuration", acctest.Required, acctest.Create, RecoveryprotectedDatabaseFetchConfigurationSingularDataSourceRepresentation) + |
| 47 | + compartmentIdVariableStr + RecoveryProtectedDatabaseFetchConfigurationResourceConfig, |
| 48 | + Check: acctest.ComposeAggregateTestCheckFuncWrapper( |
| 49 | + resource.TestCheckResourceAttr(singularDatasourceName, "base64_encode_content", "true"), |
| 50 | + resource.TestCheckResourceAttrSet(singularDatasourceName, "protected_database_id"), |
| 51 | + |
| 52 | + resource.TestCheckResourceAttrSet(singularDatasourceName, "content"), |
| 53 | + ), |
| 54 | + }, |
| 55 | + |
| 56 | + { |
| 57 | + Config: config + |
| 58 | + acctest.GenerateDataSourceFromRepresentationMap("oci_recovery_protected_database_fetch_configuration", "test_protected_database_fetch_configuration", acctest.Optional, acctest.Create, RecoveryprotectedDatabaseFetchConfigurationSingularDataSourceRepresentation) + |
| 59 | + compartmentIdVariableStr + RecoveryProtectedDatabaseFetchConfigurationResourceConfig, |
| 60 | + Check: acctest.ComposeAggregateTestCheckFuncWrapper( |
| 61 | + resource.TestCheckResourceAttr(singularDatasourceName, "base64_encode_content", "false"), |
| 62 | + resource.TestCheckResourceAttr(singularDatasourceName, "configuration_type", "ALL"), |
| 63 | + resource.TestCheckResourceAttrSet(singularDatasourceName, "protected_database_id"), |
| 64 | + |
| 65 | + resource.TestCheckResourceAttrSet(singularDatasourceName, "content"), |
| 66 | + ), |
| 67 | + }, |
| 68 | + }) |
| 69 | +} |
0 commit comments