From f88b55e2def6d60387859f028dbc4f1e7c0f6a62 Mon Sep 17 00:00:00 2001 From: 1riatsila1 Date: Mon, 11 Nov 2024 09:12:21 +0400 Subject: [PATCH] Revert "feat: acceptance test for sensor group assignment resource" This reverts commit 3871bf076c85b9830788283dc61318a602e267c2. --- .../resources/sensor_group_assignment_test.go | 120 ------------------ test/live/util/sensor.go | 36 ------ test/mocked/util/utils.go | 10 +- 3 files changed, 3 insertions(+), 163 deletions(-) delete mode 100644 test/live/resources/sensor_group_assignment_test.go delete mode 100644 test/live/util/sensor.go diff --git a/test/live/resources/sensor_group_assignment_test.go b/test/live/resources/sensor_group_assignment_test.go deleted file mode 100644 index b3c4ef97..00000000 --- a/test/live/resources/sensor_group_assignment_test.go +++ /dev/null @@ -1,120 +0,0 @@ -package resource_test - -import ( - "testing" - - "github.com/aruba-uxi/terraform-provider-configuration/test/live/config" - "github.com/aruba-uxi/terraform-provider-configuration/test/live/provider" - "github.com/aruba-uxi/terraform-provider-configuration/test/live/util" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/nbio/st" -) - -func TestSensorGroupAssignmentResource(t *testing.T) { - const groupName = "tf_provider_acceptance_test_sensor_association_test" - const group2Name = "tf_provider_acceptance_test_sensor_association_test_two" - existingSensorProperties := util.GetSensorProperties(config.SensorUid) - - resource.Test(t, resource.TestCase{ - ProtoV6ProviderFactories: provider.TestAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - // Creating a sensor group assignment - { - Config: provider.ProviderConfig + ` - resource "uxi_group" "my_group" { - name = "` + groupName + `" - } - - resource "uxi_sensor" "my_sensor" { - name = "` + existingSensorProperties.Name + `" - address_note = "` + *existingSensorProperties.AddressNotes + `" - notes = "` + *existingSensorProperties.Notes + `" - pcap_mode = "` + *existingSensorProperties.PcapMode + `" - } - - import { - to = uxi_sensor.my_sensor - id = "` + config.SensorUid + `" - } - - resource "uxi_sensor_group_assignment" "my_sensor_group_assignment" { - sensor_id = uxi_sensor.my_sensor.id - group_id = uxi_group.my_group.id - }`, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr( - "uxi_sensor_group_assignment.my_sensor_group_assignment", - "sensor_id", - config.SensorUid, - ), - resource.TestCheckResourceAttrWith( - "uxi_sensor_group_assignment.my_sensor_group_assignment", - "group_id", - func(value string) error { - st.Assert(t, value, util.GetGroupByName(groupName).Id) - return nil - }, - ), - ), - }, - // ImportState testing - { - ResourceName: "uxi_sensor_group_assignment.my_sensor_group_assignment", - ImportState: true, - ImportStateVerify: true, - }, - // Update and Read testing - { - Config: provider.ProviderConfig + ` - // the original resources - resource "uxi_group" "my_group" { - name = "` + groupName + `" - } - - resource "uxi_sensor" "my_sensor" { - name = "` + existingSensorProperties.Name + `" - address_note = "` + *existingSensorProperties.AddressNotes + `" - notes = "` + *existingSensorProperties.Notes + `" - pcap_mode = "` + *existingSensorProperties.PcapMode + `" - } - - // the new resources we wanna update the assignment to - resource "uxi_group" "my_group_2" { - name = "` + group2Name + `" - } - - // the assignment update, updated from sensor/group to sensor/group_2 - resource "uxi_sensor_group_assignment" "my_sensor_group_assignment" { - sensor_id = uxi_sensor.my_sensor_2.id - group_id = uxi_group.my_group_2.id - }`, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr( - "uxi_sensor_group_assignment.my_sensor_group_assignment", - "sensor_id", - config.SensorUid, - ), - resource.TestCheckResourceAttrWith( - "uxi_sensor_group_assignment.my_sensor_group_assignment", - "group_id", - func(value string) error { - st.Assert(t, value, util.GetGroupByName(group2Name).Id) - return nil - }, - ), - ), - }, - // Delete sensor-group assignments and remove sensors from state - { - Config: provider.ProviderConfig + ` - removed { - from = uxi_sensor.my_sensor - - lifecycle { - destroy = false - } - }`, - }, - }, - }) -} diff --git a/test/live/util/sensor.go b/test/live/util/sensor.go deleted file mode 100644 index cbf81019..00000000 --- a/test/live/util/sensor.go +++ /dev/null @@ -1,36 +0,0 @@ -package util - -import ( - "context" -) - -type sensorProperties struct { - Id string - Name string - Notes *string - AddressNotes *string - PcapMode *string -} - -func GetSensorProperties(id string) sensorProperties { - result, _, err := Client.ConfigurationAPI. - SensorsGet(context.Background()). - Id(id). - Execute() - if err != nil { - panic(err) - } - if len(result.Items) != 1 { - panic("sensor with id `" + id + "` could not be found") - } - sensor := result.Items[0] - // Read these in, as they may not be always constant with the acceptance test - // customer - return sensorProperties{ - Id: sensor.Id, - Name: sensor.Name, - Notes: sensor.Notes.Get(), - AddressNotes: sensor.AddressNote.Get(), - PcapMode: sensor.PcapMode.Get(), - } -} diff --git a/test/mocked/util/utils.go b/test/mocked/util/utils.go index 58b90536..6bcb7a2e 100644 --- a/test/mocked/util/utils.go +++ b/test/mocked/util/utils.go @@ -26,10 +26,6 @@ func GenerateSensorResponseModel(uid string, postfix string) map[string]interfac } func GenerateMockedSensorResponseModel(uid string, postfix string) resources.SensorResponseModel { - addressNote := "address_note" + postfix - notes := "notes" + postfix - pcapMode := "light" + postfix - return resources.SensorResponseModel{ UID: uid, Serial: "serial" + postfix, @@ -37,11 +33,11 @@ func GenerateMockedSensorResponseModel(uid string, postfix string) resources.Sen ModelNumber: "model_number" + postfix, WifiMacAddress: "wifi_mac_address" + postfix, EthernetMacAddress: "ethernet_mac_address" + postfix, - AddressNote: &addressNote, + AddressNote: "address_note" + postfix, Longitude: 0.0, Latitude: 0.0, - Notes: ¬es, - PCapMode: &pcapMode, + Notes: "notes" + postfix, + PCapMode: "light" + postfix, } }