From daa6fc5f7e82b1611b4aeac5099191d2de4c1c3f Mon Sep 17 00:00:00 2001 From: 1riatsila1 Date: Mon, 9 Dec 2024 16:27:00 +0200 Subject: [PATCH] Make tests more brief --- test/mocked/resources/agent_test.go | 28 ----------------------- test/mocked/resources/sensor_test.go | 34 +--------------------------- 2 files changed, 1 insertion(+), 61 deletions(-) diff --git a/test/mocked/resources/agent_test.go b/test/mocked/resources/agent_test.go index dd2fbc2..ca644e3 100644 --- a/test/mocked/resources/agent_test.go +++ b/test/mocked/resources/agent_test.go @@ -109,30 +109,10 @@ func TestAgentResource(t *testing.T) { func Test_AgentResource_WithInvalidPcapMode_ShouldFail(t *testing.T) { defer gock.Off() mockOAuth := util.MockOAuth() - agent := util.GenerateAgentsGetResponse("id", "").Items[0] resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: provider.TestAccProtoV6ProviderFactories, Steps: []resource.TestStep{ - // Importing an agent - { - PreConfig: func() { - util.MockGetAgent("id", util.GenerateAgentsGetResponse("id", ""), 2) - }, - Config: provider.ProviderConfig + ` - resource "hpeuxi_agent" "my_agent" { - name = "name" - notes = "notes" - pcap_mode = "light" - } - - import { - to = hpeuxi_agent.my_agent - id = "id" - }`, - - Check: shared.CheckStateAgainstAgent(t, "hpeuxi_agent.my_agent", agent), - }, // agent with invalid pcap_mode { Config: provider.ProviderConfig + ` @@ -145,14 +125,6 @@ func Test_AgentResource_WithInvalidPcapMode_ShouldFail(t *testing.T) { `(?s)Attribute pcap_mode value must be one of: \["light" "full" "off"\], got:\s*"invalid_pcap_mode"`, ), }, - // Deleting - { - PreConfig: func() { - util.MockGetAgent("id", util.GenerateAgentsGetResponse("id", ""), 1) - util.MockDeleteAgent("id", 1) - }, - Config: provider.ProviderConfig, - }, }, }) diff --git a/test/mocked/resources/sensor_test.go b/test/mocked/resources/sensor_test.go index 4bb14c0..b5bef02 100644 --- a/test/mocked/resources/sensor_test.go +++ b/test/mocked/resources/sensor_test.go @@ -129,32 +129,11 @@ func TestSensorResource(t *testing.T) { func Test_SensorResource_WithInvalidPcapMode_ShouldFail(t *testing.T) { defer gock.Off() mockOAuth := util.MockOAuth() - sensor := util.GenerateSensorsGetResponse("id", "").Items[0] resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: provider.TestAccProtoV6ProviderFactories, Steps: []resource.TestStep{ - // Importing a sensor - { - PreConfig: func() { - util.MockGetSensor("id", util.GenerateSensorsGetResponse("id", ""), 2) - }, - Config: provider.ProviderConfig + ` - resource "hpeuxi_sensor" "my_sensor" { - name = "name" - address_note = "address_note" - notes = "notes" - pcap_mode = "light" - } - - import { - to = hpeuxi_sensor.my_sensor - id = "id" - }`, - - Check: shared.CheckStateAgainstSensor(t, "hpeuxi_sensor.my_sensor", sensor), - }, - // Updating sensor with invalid pcap_mode + // sensor with invalid pcap_mode { Config: provider.ProviderConfig + ` resource "hpeuxi_sensor" "my_sensor" { @@ -167,17 +146,6 @@ func Test_SensorResource_WithInvalidPcapMode_ShouldFail(t *testing.T) { `(?s)Attribute pcap_mode value must be one of: \["light" "full" "off"\], got:\s*"invalid_pcap_mode"`, ), }, - // Remove sensor from state - { - Config: provider.ProviderConfig + ` - removed { - from = hpeuxi_sensor.my_sensor - - lifecycle { - destroy = false - } - }`, - }, }, })