@@ -75,6 +75,35 @@ func TestAccTFEOAuthClient_rsaKeys(t *testing.T) {
75
75
})
76
76
}
77
77
78
+ func TestAccTFEOAuthClient_agentPool (t * testing.T ) {
79
+ oc := & tfe.OAuthClient {}
80
+ rInt := rand .New (rand .NewSource (time .Now ().UnixNano ())).Int ()
81
+
82
+ resource .Test (t , resource.TestCase {
83
+ PreCheck : func () {
84
+ testAccPreCheck (t )
85
+ if envGithubToken == "" {
86
+ t .Skip ("Please set GITHUB_TOKEN to run this test" )
87
+ }
88
+ },
89
+ Providers : testAccProviders ,
90
+ CheckDestroy : testAccCheckTFEOAuthClientDestroy ,
91
+ Steps : []resource.TestStep {
92
+ {
93
+ Config : testAccTFEOAuthClient_agentPool (rInt ),
94
+ Check : resource .ComposeTestCheckFunc (
95
+ testAccCheckTFEOAuthClientExists ("tfe_oauth_client.foobar" , oc ),
96
+ testAccCheckTFEOAuthClientAttributes (oc ),
97
+ resource .TestCheckResourceAttr (
98
+ "tfe_oauth_client.foobar" , "service_provider" , "github_enterprise" ),
99
+ resource .TestCheckResourceAttr (
100
+ "tfe_workspace.foobar" , "agent_pool_id" , "" ),
101
+ ),
102
+ },
103
+ },
104
+ })
105
+ }
106
+
78
107
func testAccCheckTFEOAuthClientExists (
79
108
n string , oc * tfe.OAuthClient ) resource.TestCheckFunc {
80
109
return func (s * terraform.State ) error {
@@ -183,3 +212,25 @@ hwIDAQAB
183
212
EOT
184
213
}` , rInt )
185
214
}
215
+
216
+ func testAccTFEOAuthClient_agentPool (rInt int ) string {
217
+ return fmt .Sprintf (`
218
+ resource "tfe_organization" "foobar" {
219
+ name = "tst-terraform-%d"
220
+
221
+ }
222
+
223
+ resource "tfe_agent_pool" "foobar" {
224
+ name = "agent-pool-test"
225
+ organization = tfe_organization.foobar.name
226
+ }
227
+
228
+ resource "tfe_oauth_client" "foobar" {
229
+ organization = tfe_organization.foobar.id
230
+ api_url = "https://githubenterprise.xxx"
231
+ http_url = "https://githubenterprise.xxx"
232
+ oauth_token = "%s"
233
+ service_provider = "github_enterprise"
234
+ agent_pool_id = tfe_agent_pool.foobar.id
235
+ }` , rInt , envGithubToken )
236
+ }
0 commit comments