|
| 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 | + UsageProxyUsagelimitDataSourceRepresentation = map[string]interface{}{ |
| 20 | + "compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`}, |
| 21 | + "subscription_id": acctest.Representation{RepType: acctest.Required, Create: `${var.subscription_id}`}, |
| 22 | + "limit_type": acctest.Representation{RepType: acctest.Optional, Create: `limitType`}, |
| 23 | + "resource_type": acctest.Representation{RepType: acctest.Optional, Create: `resourceType`}, |
| 24 | + "service_type": acctest.Representation{RepType: acctest.Optional, Create: `serviceType`}, |
| 25 | + } |
| 26 | + |
| 27 | + UsageProxyUsagelimitResourceConfig = "" |
| 28 | +) |
| 29 | + |
| 30 | +// issue-routing-tag: usage_proxy/default |
| 31 | +func TestUsageProxyUsagelimitResource_basic(t *testing.T) { |
| 32 | + httpreplay.SetScenario("TestUsageProxyUsagelimitResource_basic") |
| 33 | + defer httpreplay.SaveScenario() |
| 34 | + |
| 35 | + config := acctest.ProviderTestConfig() |
| 36 | + |
| 37 | + compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid") |
| 38 | + compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId) |
| 39 | + |
| 40 | + subscriptionId := utils.GetEnvSettingWithBlankDefault("subscription_id") |
| 41 | + subscriptionIdVariableStr := fmt.Sprintf("variable \"subscription_id\" { default = \"%s\" }\n", subscriptionId) |
| 42 | + |
| 43 | + datasourceName := "data.oci_usage_proxy_usagelimits.test_usagelimits" |
| 44 | + |
| 45 | + acctest.SaveConfigContent("", "", "", t) |
| 46 | + |
| 47 | + acctest.ResourceTest(t, nil, []resource.TestStep{ |
| 48 | + // verify datasource |
| 49 | + { |
| 50 | + Config: config + |
| 51 | + acctest.GenerateDataSourceFromRepresentationMap("oci_usage_proxy_usagelimits", "test_usagelimits", acctest.Required, acctest.Create, UsageProxyUsagelimitDataSourceRepresentation) + |
| 52 | + compartmentIdVariableStr + subscriptionIdVariableStr + UsageProxyUsagelimitResourceConfig, |
| 53 | + Check: acctest.ComposeAggregateTestCheckFuncWrapper( |
| 54 | + resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId), |
| 55 | + |
| 56 | + resource.TestCheckResourceAttrSet(datasourceName, "usage_limit_collection.#"), |
| 57 | + resource.TestCheckResourceAttr(datasourceName, "usage_limit_collection.0.items.#", "1"), |
| 58 | + resource.TestCheckResourceAttrSet(datasourceName, "usage_limit_collection.0.items.0.entitlement_id"), |
| 59 | + resource.TestCheckResourceAttrSet(datasourceName, "usage_limit_collection.0.items.0.limit_type"), |
| 60 | + ), |
| 61 | + }, |
| 62 | + }) |
| 63 | +} |
0 commit comments