|
| 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 | + "testing" |
| 8 | + |
| 9 | + "github.com/hashicorp/terraform-plugin-testing/helper/resource" |
| 10 | + |
| 11 | + "github.com/oracle/terraform-provider-oci/httpreplay" |
| 12 | + "github.com/oracle/terraform-provider-oci/internal/acctest" |
| 13 | + |
| 14 | + "github.com/oracle/terraform-provider-oci/internal/utils" |
| 15 | +) |
| 16 | + |
| 17 | +var ( |
| 18 | + JmsFleetErrorCompartmentId = utils.GetEnvSettingWithBlankDefault("compartment_ocid") |
| 19 | + JmsFleetErrorFleetId = utils.GetEnvSettingWithBlankDefault("fleet_advanced_feature_ocid") |
| 20 | + JmsFleetErrorDataSourceRepresentation = map[string]interface{}{ |
| 21 | + "compartment_id": acctest.Representation{RepType: acctest.Optional, Create: JmsFleetErrorCompartmentId}, |
| 22 | + "compartment_id_in_subtree": acctest.Representation{RepType: acctest.Optional, Create: `false`}, |
| 23 | + "fleet_id": acctest.Representation{RepType: acctest.Optional, Create: JmsFleetErrorFleetId}, |
| 24 | + } |
| 25 | + |
| 26 | + JmsFleetErrorResourceConfig = acctest.GenerateResourceFromRepresentationMap("oci_jms_fleet", "test_fleet", acctest.Required, acctest.Create, JmsFleetRepresentation) |
| 27 | +) |
| 28 | + |
| 29 | +// issue-routing-tag: jms/default |
| 30 | +func TestJmsFleetErrorResource_basic(t *testing.T) { |
| 31 | + httpreplay.SetScenario("TestJmsFleetErrorResource_basic") |
| 32 | + defer httpreplay.SaveScenario() |
| 33 | + |
| 34 | + config := acctest.ProviderTestConfig() |
| 35 | + |
| 36 | + datasourceName := "data.oci_jms_fleet_errors.test_fleet_errors" |
| 37 | + |
| 38 | + acctest.ResourceTest(t, nil, []resource.TestStep{ |
| 39 | + // verify create |
| 40 | + // note: we cannot write test for this case because |
| 41 | + // we don't have create API. |
| 42 | + |
| 43 | + // verify update |
| 44 | + // note: we cannot write test for this case because |
| 45 | + // we don't have update API. |
| 46 | + |
| 47 | + // verify datasource |
| 48 | + { |
| 49 | + Config: config + |
| 50 | + acctest.GenerateDataSourceFromRepresentationMap( |
| 51 | + "oci_jms_fleet_errors", |
| 52 | + "test_fleet_errors", |
| 53 | + acctest.Optional, |
| 54 | + acctest.Create, |
| 55 | + JmsFleetErrorDataSourceRepresentation) + |
| 56 | + JmsFleetErrorResourceConfig, |
| 57 | + Check: acctest.ComposeAggregateTestCheckFuncWrapper( |
| 58 | + resource.TestCheckResourceAttr(datasourceName, "compartment_id", JmsFleetErrorCompartmentId), |
| 59 | + resource.TestCheckResourceAttr(datasourceName, "compartment_id_in_subtree", "false"), |
| 60 | + resource.TestCheckResourceAttr(datasourceName, "fleet_id", JmsFleetErrorFleetId), |
| 61 | + |
| 62 | + resource.TestCheckResourceAttrSet(datasourceName, "fleet_error_collection.#"), |
| 63 | + // we can only verify that response contain zero items because we are using dummy test data values |
| 64 | + // we cannot use actual values because it requires create API. |
| 65 | + resource.TestCheckResourceAttr(datasourceName, "fleet_error_collection.0.items.#", "0"), |
| 66 | + ), |
| 67 | + }, |
| 68 | + // verify singular datasource |
| 69 | + // note: we cannot write test to verify singular data source because |
| 70 | + // crypto analysis processing requires create API. |
| 71 | + }) |
| 72 | +} |
0 commit comments