From e021a65dce6e14eb706e89b9b04e210eb652e0e9 Mon Sep 17 00:00:00 2001 From: francesco-racciatti Date: Fri, 21 Apr 2023 12:25:15 +0200 Subject: [PATCH] test: add tests covering both direct connection and orchestrated modes Signed-off-by: francesco-racciatti --- ...urce_sysdig_fargate_workload_agent_test.go | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/sysdig/data_source_sysdig_fargate_workload_agent_test.go b/sysdig/data_source_sysdig_fargate_workload_agent_test.go index be364974..5876ccc8 100644 --- a/sysdig/data_source_sysdig_fargate_workload_agent_test.go +++ b/sysdig/data_source_sysdig_fargate_workload_agent_test.go @@ -11,7 +11,8 @@ import ( "github.com/draios/terraform-provider-sysdig/sysdig" ) -func TestAccSysdigFargateWorkloadAgent(t *testing.T) { +// Direct connection mode has been deprecated in Prod envs +func TestAccSysdigFargateWorkloadAgentDirectConnection(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ ProviderFactories: map[string]func() (*schema.Provider, error){ "sysdig": func() (*schema.Provider, error) { @@ -20,13 +21,13 @@ func TestAccSysdigFargateWorkloadAgent(t *testing.T) { }, Steps: []resource.TestStep{ { - Config: getFargateWorkloadAgent(), + Config: getFargateWorkloadAgentDirectConnection(), }, }, }) } -func getFargateWorkloadAgent() string { +func getFargateWorkloadAgentDirectConnection() string { return ` data "sysdig_fargate_workload_agent" "test" { container_definitions = "[]" @@ -40,3 +41,31 @@ data "sysdig_fargate_workload_agent" "test" { } ` } + +func TestAccSysdigFargateWorkloadAgentOrchestrated(t *testing.T) { + resource.ParallelTest(t, resource.TestCase{ + ProviderFactories: map[string]func() (*schema.Provider, error){ + "sysdig": func() (*schema.Provider, error) { + return sysdig.Provider(), nil + }, + }, + Steps: []resource.TestStep{ + { + Config: getFargateWorkloadAgentOrchestrated(), + }, + }, + }) +} + +func getFargateWorkloadAgentOrchestrated() string { + return ` +data "sysdig_fargate_workload_agent" "test" { + container_definitions = "[]" + + orchestrator_host = "sysdig.orchestrator.agent.com" + orchestrator_port = 6667 + workload_agent_image = "quay.io/sysdig/workload-agent:latest" + sysdig_logging = "info" +} +` +}