@@ -13,10 +13,12 @@ func TestAgentPoolsList(t *testing.T) {
1313 client := testClient (t )
1414 ctx := context .Background ()
1515
16- agentPoolTest1 , agentPoolTest1Cleanup := createAgentPool (t , client )
16+ agentPoolTest1 , agentPoolTest1Cleanup := createAgentPool (t , client , false )
1717 defer agentPoolTest1Cleanup ()
18- agentPoolTest2 , agentPoolTest2Cleanup := createAgentPool (t , client )
18+ agentPoolTest2 , agentPoolTest2Cleanup := createAgentPool (t , client , true )
1919 defer agentPoolTest2Cleanup ()
20+ agentPoolTest3 , agentPoolTest3Cleanup := createAgentPool (t , client , true )
21+ defer agentPoolTest3Cleanup ()
2022
2123 t .Run ("without options" , func (t * testing.T ) {
2224 apList , err := client .AgentPools .List (ctx , AgentPoolListOptions {})
@@ -27,6 +29,7 @@ func TestAgentPoolsList(t *testing.T) {
2729 }
2830 assert .Contains (t , apListIDs , agentPoolTest1 .ID )
2931 assert .Contains (t , apListIDs , agentPoolTest2 .ID )
32+ assert .Contains (t , apListIDs , agentPoolTest3 .ID )
3033 })
3134 t .Run ("with account filter" , func (t * testing.T ) {
3235 apList , err := client .AgentPools .List (ctx , AgentPoolListOptions {Account : String (defaultAccountID )})
@@ -37,6 +40,7 @@ func TestAgentPoolsList(t *testing.T) {
3740 }
3841 assert .Contains (t , apListIDs , agentPoolTest1 .ID )
3942 assert .Contains (t , apListIDs , agentPoolTest2 .ID )
43+ assert .Contains (t , apListIDs , agentPoolTest3 .ID )
4044 })
4145 t .Run ("with account and name filter" , func (t * testing.T ) {
4246 apList , err := client .AgentPools .List (ctx , AgentPoolListOptions {Account : String (defaultAccountID ), Name : agentPoolTest1 .Name })
@@ -50,6 +54,18 @@ func TestAgentPoolsList(t *testing.T) {
5054 assert .Len (t , apList .Items , 1 )
5155 assert .Equal (t , apList .Items [0 ].ID , agentPoolTest2 .ID )
5256 })
57+ t .Run ("with vcs-enabled filter" , func (t * testing.T ) {
58+ var vcsEnabledFiler = true
59+ apList , err := client .AgentPools .List (ctx , AgentPoolListOptions {VcsEnabled : & vcsEnabledFiler })
60+ require .NoError (t , err )
61+ apListIDs := make ([]string , 0 )
62+ for _ , agentPool := range apList .Items {
63+ apListIDs = append (apListIDs , agentPool .ID )
64+ }
65+ assert .Len (t , apListIDs , 2 )
66+ assert .Contains (t , apListIDs , agentPoolTest2 .ID )
67+ assert .Contains (t , apListIDs , agentPoolTest3 .ID )
68+ })
5369}
5470
5571func TestAgentPoolsCreate (t * testing.T ) {
@@ -58,8 +74,9 @@ func TestAgentPoolsCreate(t *testing.T) {
5874
5975 t .Run ("when account and name are provided" , func (t * testing.T ) {
6076 options := AgentPoolCreateOptions {
61- Account : & Account {ID : defaultAccountID },
62- Name : String ("test-provider-pool-" + randomString (t )),
77+ Account : & Account {ID : defaultAccountID },
78+ Name : String ("test-provider-pool-" + randomString (t )),
79+ VcsEnabled : Bool (true ),
6380 }
6481
6582 agentPool , err := client .AgentPools .Create (ctx , options )
@@ -76,6 +93,31 @@ func TestAgentPoolsCreate(t *testing.T) {
7693 assert .NotEmpty (t , item .ID )
7794 assert .Equal (t , * options .Name , item .Name )
7895 assert .Equal (t , options .Account , item .Account )
96+ assert .Equal (t , * options .VcsEnabled , item .VcsEnabled )
97+ }
98+ err = client .AgentPools .Delete (ctx , agentPool .ID )
99+ require .NoError (t , err )
100+ })
101+
102+ t .Run ("when create without vcs_enabled" , func (t * testing.T ) {
103+ options := AgentPoolCreateOptions {
104+ Account : & Account {ID : defaultAccountID },
105+ Name : String ("test-provider-pool-" + randomString (t )),
106+ }
107+
108+ agentPool , err := client .AgentPools .Create (ctx , options )
109+ require .NoError (t , err )
110+
111+ // Get a refreshed view from the API.
112+ refreshed , err := client .AgentPools .Read (ctx , agentPool .ID )
113+ require .NoError (t , err )
114+
115+ for _ , item := range []* AgentPool {
116+ agentPool ,
117+ refreshed ,
118+ } {
119+ assert .NotEmpty (t , item .ID )
120+ assert .Equal (t , item .VcsEnabled , false )
79121 }
80122 err = client .AgentPools .Delete (ctx , agentPool .ID )
81123 require .NoError (t , err )
@@ -90,6 +132,7 @@ func TestAgentPoolsCreate(t *testing.T) {
90132 Account : & Account {ID : defaultAccountID },
91133 Environment : & Environment {ID : env .ID },
92134 Name : String ("test-provider-pool-" + randomString (t )),
135+ VcsEnabled : Bool (false ),
93136 }
94137
95138 agentPool , err := client .AgentPools .Create (ctx , options )
@@ -123,6 +166,7 @@ func TestAgentPoolsCreate(t *testing.T) {
123166 Environment : & Environment {ID : env .ID },
124167 Workspaces : []* Workspace {{ID : ws .ID }},
125168 Name : String ("test-provider-pool-" + randomString (t )),
169+ VcsEnabled : Bool (false ),
126170 }
127171
128172 agentPool , err := client .AgentPools .Create (ctx , options )
@@ -241,7 +285,7 @@ func TestAgentPoolsRead(t *testing.T) {
241285 client := testClient (t )
242286 ctx := context .Background ()
243287
244- agentPoolTest , agentPoolTestCleanup := createAgentPool (t , client )
288+ agentPoolTest , agentPoolTestCleanup := createAgentPool (t , client , false )
245289 defer agentPoolTestCleanup ()
246290
247291 t .Run ("when the agentPool exists" , func (t * testing.T ) {
@@ -278,7 +322,7 @@ func TestAgentPoolsUpdate(t *testing.T) {
278322 client := testClient (t )
279323 ctx := context .Background ()
280324
281- agentPoolTest , agentPoolTestCleanup := createAgentPool (t , client )
325+ agentPoolTest , agentPoolTestCleanup := createAgentPool (t , client , false )
282326 defer agentPoolTestCleanup ()
283327
284328 t .Run ("when updating a name" , func (t * testing.T ) {
@@ -337,7 +381,7 @@ func TestAgentPoolsDelete(t *testing.T) {
337381 client := testClient (t )
338382 ctx := context .Background ()
339383
340- pool , _ := createAgentPool (t , client )
384+ pool , _ := createAgentPool (t , client , false )
341385
342386 t .Run ("with valid agent pool id" , func (t * testing.T ) {
343387 err := client .AgentPools .Delete (ctx , pool .ID )
0 commit comments