From 907f63244bbecb9f21ed557315f9a74b4ad5a2b0 Mon Sep 17 00:00:00 2001 From: Jarrett Spiker Date: Tue, 31 May 2022 16:22:27 -0400 Subject: [PATCH] Add query option to agent pool list options --- agent_pool.go | 2 ++ agent_pool_integration_test.go | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/agent_pool.go b/agent_pool.go index f2913efb7..e8cbd6586 100644 --- a/agent_pool.go +++ b/agent_pool.go @@ -70,6 +70,8 @@ type AgentPoolListOptions struct { // Optional: A list of relations to include. See available resources // https://www.terraform.io/cloud-docs/api-docs/agents#available-related-resources Include []AgentPoolIncludeOpt `url:"include,omitempty"` + + Query string `url:"q,omitempty"` } // AgentPoolCreateOptions represents the options for creating an agent pool. diff --git a/agent_pool_integration_test.go b/agent_pool_integration_test.go index 5b0e98c53..c472d3d77 100644 --- a/agent_pool_integration_test.go +++ b/agent_pool_integration_test.go @@ -69,6 +69,21 @@ func TestAgentPoolsList(t *testing.T) { assert.Nil(t, pools) assert.EqualError(t, err, ErrInvalidOrg.Error()) }) + + t.Run("with query options", func(t *testing.T) { + + pools, err := client.AgentPools.List(ctx, orgTest.Name, &AgentPoolListOptions{ + Query: agentPool.Name, + }) + require.NoError(t, err) + assert.Equal(t, len(pools.Items), 1) + + pools, err = client.AgentPools.List(ctx, orgTest.Name, &AgentPoolListOptions{ + Query: agentPool.Name + "not_going_to_match", + }) + require.NoError(t, err) + assert.Empty(t, pools.Items) + }) } func TestAgentPoolsCreate(t *testing.T) {