Skip to content

Commit

Permalink
Make tests more brief
Browse files Browse the repository at this point in the history
  • Loading branch information
1riatsila1 committed Dec 9, 2024
1 parent c1a09c2 commit daa6fc5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 61 deletions.
28 changes: 0 additions & 28 deletions test/mocked/resources/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 + `
Expand All @@ -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,
},
},
})

Expand Down
34 changes: 1 addition & 33 deletions test/mocked/resources/sensor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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
}
}`,
},
},
})

Expand Down

0 comments on commit daa6fc5

Please sign in to comment.