Skip to content

Commit

Permalink
Add query option to agent pool list options
Browse files Browse the repository at this point in the history
  • Loading branch information
JarrettSpiker committed Jun 8, 2022
1 parent 5a2a37b commit e7740b3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions agent_pool.go
Expand Up @@ -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.
Expand Down
15 changes: 15 additions & 0 deletions agent_pool_integration_test.go
Expand Up @@ -68,6 +68,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) {
Expand Down

0 comments on commit e7740b3

Please sign in to comment.