|
| 1 | +// Copyright (c) 2017, 2024, 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-testing/helper/resource" |
| 11 | + |
| 12 | + oci_dblm "github.com/oracle/oci-go-sdk/v65/dblm" |
| 13 | + "github.com/oracle/terraform-provider-oci/httpreplay" |
| 14 | + "github.com/oracle/terraform-provider-oci/internal/acctest" |
| 15 | + |
| 16 | + "github.com/oracle/terraform-provider-oci/internal/utils" |
| 17 | +) |
| 18 | + |
| 19 | +var ( |
| 20 | + DblmPatchManagementDatabaseDataSourceRepresentation = map[string]interface{}{ |
| 21 | + "compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`}, |
| 22 | + "database_release": acctest.Representation{RepType: acctest.Optional, Create: `19.0.0.0.0`}, |
| 23 | + "database_type": acctest.Representation{RepType: acctest.Optional, Create: `SI`}, |
| 24 | + "display_name": acctest.Representation{RepType: acctest.Optional, Create: `displayName`}, |
| 25 | + "drifter_patch_id": acctest.Representation{RepType: acctest.Optional, Create: `1`}, |
| 26 | + "image_compliance": acctest.Representation{RepType: acctest.Optional, Create: `NOT_SUBSCRIBED`}, |
| 27 | + "image_id": acctest.Representation{RepType: acctest.Optional, Create: `imageId`}, |
| 28 | + "severity_type": acctest.Representation{RepType: acctest.Optional, Create: []oci_dblm.ResourcesSeveritiesEnum{`CRITICAL`}}, |
| 29 | + "state": acctest.Representation{RepType: acctest.Optional, Create: `ACTIVE`}, |
| 30 | + } |
| 31 | + |
| 32 | + DblmPatchManagementDatabaseResourceConfig = "" |
| 33 | +) |
| 34 | + |
| 35 | +// issue-routing-tag: dblm/default |
| 36 | +func TestDblmPatchManagementDatabaseResource_basic(t *testing.T) { |
| 37 | + httpreplay.SetScenario("TestDblmPatchManagementDatabaseResource_basic") |
| 38 | + defer httpreplay.SaveScenario() |
| 39 | + |
| 40 | + config := acctest.ProviderTestConfig() |
| 41 | + |
| 42 | + // compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid") |
| 43 | + compartmentId := utils.GetEnvSettingWithBlankDefault("tenancy_ocid") |
| 44 | + // tenantId := utils.GetEnvSettingWithBlankDefault("tenancy_ocid") |
| 45 | + patchTypePlatformConfigurationId := utils.GetEnvSettingWithBlankDefault("test_patch_type_platform_configuration_id") |
| 46 | + productPlatformConfigurationId := utils.GetEnvSettingWithBlankDefault("test_product_platform_configuration_id") |
| 47 | + |
| 48 | + platformConfigurationsStr := fmt.Sprintf( |
| 49 | + "variable \"patch_type_platform_configuration_id\" { default = \"%s\" }\n"+ |
| 50 | + "variable \"product_platform_configuration_id\" { default = \"%s\" }\n"+ |
| 51 | + "variable \"compartment_id\" { default = \"%s\" }\n", |
| 52 | + patchTypePlatformConfigurationId, productPlatformConfigurationId, compartmentId) |
| 53 | + |
| 54 | + datasourceName := "data.oci_dblm_patch_management_databases.test_dblm_patch_management_databases" |
| 55 | + |
| 56 | + acctest.SaveConfigContent("", "", "", t) |
| 57 | + |
| 58 | + acctest.ResourceTest(t, nil, []resource.TestStep{ |
| 59 | + // verify datasource |
| 60 | + { |
| 61 | + Config: config + |
| 62 | + acctest.GenerateDataSourceFromRepresentationMap("oci_dblm_patch_management_databases", "test_dblm_patch_management_databases", acctest.Optional, acctest.Create, DblmPatchManagementDatabaseDataSourceRepresentation) + |
| 63 | + platformConfigurationsStr + DblmPatchManagementDatabaseResourceConfig, |
| 64 | + Check: acctest.ComposeAggregateTestCheckFuncWrapper( |
| 65 | + resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId), |
| 66 | + resource.TestCheckResourceAttr(datasourceName, "database_release", "19.0.0.0.0"), |
| 67 | + resource.TestCheckResourceAttr(datasourceName, "database_type", "SI"), |
| 68 | + resource.TestCheckResourceAttr(datasourceName, "state", "ACTIVE"), |
| 69 | + |
| 70 | + resource.TestCheckResourceAttrSet(datasourceName, "patch_databases_collection.#"), |
| 71 | + ), |
| 72 | + }, |
| 73 | + }) |
| 74 | +} |
0 commit comments