@@ -58,11 +58,11 @@ func TestAccIbmSchematicsAgentBasic(t *testing.T) {
5858func TestAccIbmSchematicsAgentAllArgs (t * testing.T ) {
5959 var conf schematicsv1.AgentData
6060 name := fmt .Sprintf ("tf_name_%d" , acctest .RandIntRange (10 , 100 ))
61- version := "1.1 .0"
61+ version := "1.4 .0"
6262 schematicsLocation := "us-south"
6363 agentLocation := "eu-de"
6464 nameUpdate := fmt .Sprintf ("tf_name_%d" , acctest .RandIntRange (10 , 100 ))
65- versionUpdate := "1.2 .0"
65+ versionUpdate := "1.5 .0"
6666 schematicsLocationUpdate := "us-east"
6767 agentLocationUpdate := "eu-gb"
6868 description := fmt .Sprintf ("tf_description_%d" , acctest .RandIntRange (10 , 100 ))
@@ -94,6 +94,19 @@ func TestAccIbmSchematicsAgentAllArgs(t *testing.T) {
9494 resource .TestCheckResourceAttr ("ibm_schematics_agent.schematics_agent_instance" , "description" , descriptionUpdate ),
9595 ),
9696 },
97+ resource.TestStep {
98+ Config : testAccIbmSchematicsAgentConfig_withMetadata (name , version , schematicsLocation , agentLocation ),
99+ Check : resource .ComposeTestCheckFunc (
100+ testAccCheckIbmSchematicsAgentExists ("ibm_schematics_agent.schematics_agent_instance" , conf ),
101+ resource .TestCheckResourceAttr ("ibm_schematics_agent.schematics_agent_instance" , "name" , name ),
102+ resource .TestCheckResourceAttr ("ibm_schematics_agent.schematics_agent_instance" , "version" , version ),
103+ resource .TestCheckResourceAttr ("ibm_schematics_agent.schematics_agent_instance" , "schematics_location" , schematicsLocation ),
104+ resource .TestCheckResourceAttr ("ibm_schematics_agent.schematics_agent_instance" , "agent_location" , agentLocation ),
105+ resource .TestCheckResourceAttr ("ibm_schematics_agent.schematics_agent_instance" , "agent_metadata.#" , "2" ),
106+ resource .TestCheckResourceAttr ("ibm_schematics_agent.schematics_agent_instance" , "agent_metadata.0.name" , "purpose" ),
107+ resource .TestCheckResourceAttr ("ibm_schematics_agent.schematics_agent_instance" , "agent_metadata.0.value.0" , "terraform" ),
108+ ),
109+ },
97110 resource.TestStep {
98111 ResourceName : "ibm_schematics_agent.schematics_agent_instance" ,
99112 ImportState : true ,
@@ -151,6 +164,39 @@ func testAccCheckIbmSchematicsAgentConfig(name string, version string, schematic
151164 ` , name , version , schematicsLocation , agentLocation , description )
152165}
153166
167+ func testAccIbmSchematicsAgentConfig_withMetadata (name , version , schematicsLocation , agentLocation string ) string {
168+ return fmt .Sprintf (`
169+ resource "ibm_schematics_agent" "schematics_agent_instance" {
170+ name = "%s"
171+ resource_group = "Default"
172+ version = "%s"
173+ schematics_location = "%s"
174+ agent_location = "%s"
175+ tags = ["test-tag"]
176+ agent_infrastructure {
177+ infra_type = "ibm_kubernetes"
178+ cluster_id = "cluster_id"
179+ cluster_resource_group = "cluster_resource_group"
180+ cos_instance_name = "cos_instance_name"
181+ cos_bucket_name = "cos_bucket_name"
182+ cos_bucket_region = "cos_bucket_region"
183+ }
184+
185+ // This block triggers the loop at line 589
186+ agent_metadata {
187+ name = "purpose"
188+ value = ["terraform"]
189+ }
190+ // Adding a second block to ensure the loop handles multiple items
191+ agent_metadata {
192+ name = "purpose"
193+ value = ["testing"]
194+ }
195+
196+ }
197+ ` , name , version , schematicsLocation , agentLocation )
198+ }
199+
154200func testAccCheckIbmSchematicsAgentExists (n string , obj schematicsv1.AgentData ) resource.TestCheckFunc {
155201
156202 return func (s * terraform.State ) error {
0 commit comments