|
36 | 36 | import com.google.api.services.cloudbuild.v1.model.BuildTrigger;
|
37 | 37 | import com.google.api.services.cloudbuild.v1.model.ListBuildTriggersResponse;
|
38 | 38 | import com.google.api.services.cloudbuild.v1.model.Operation;
|
| 39 | +import com.google.api.services.cloudbuild.v1.model.PoolOption; |
39 | 40 | import com.google.api.services.cloudbuild.v1.model.RepoSource;
|
40 | 41 | import com.netflix.spinnaker.igor.RedisConfig;
|
41 | 42 | import com.netflix.spinnaker.igor.config.LockManagerConfig;
|
@@ -135,6 +136,34 @@ public void presentAccountTest() throws Exception {
|
135 | 136 | assertThat(stubCloudBuildService.findUnmatchedRequests().getRequests()).isEmpty();
|
136 | 137 | }
|
137 | 138 |
|
| 139 | + public void presentAccountTestWithPoolOption() throws Exception { |
| 140 | + PoolOption poolOption = new PoolOption(); |
| 141 | + poolOption.setName( |
| 142 | + "projects/spinnaker-gcb-test-2/locations/gcb-location/workerPools/test-pool"); |
| 143 | + BuildOptions buildOptions = new BuildOptions().setPool(poolOption); |
| 144 | + String buildRequest = objectMapper.writeValueAsString(buildRequest().setOptions(buildOptions)); |
| 145 | + String taggedBuild = objectMapper.writeValueAsString(taggedBuild()); |
| 146 | + String buildResponse = objectMapper.writeValueAsString(buildResponse()); |
| 147 | + String operationResponse = objectMapper.writeValueAsString(operationResponse()); |
| 148 | + stubCloudBuildService.stubFor( |
| 149 | + WireMock.post( |
| 150 | + urlEqualTo("/v1/projects/spinnaker-gcb-test-2/locations/gcb-locations/builds")) |
| 151 | + .withHeader("Authorization", equalTo("Bearer test-token")) |
| 152 | + .withRequestBody(equalToJson(taggedBuild)) |
| 153 | + .willReturn(aResponse().withStatus(200).withBody(operationResponse))); |
| 154 | + |
| 155 | + mockMvc |
| 156 | + .perform( |
| 157 | + post("/gcb/builds/create/gcb-account") |
| 158 | + .accept(MediaType.APPLICATION_JSON) |
| 159 | + .contentType(MediaType.APPLICATION_JSON) |
| 160 | + .content(buildRequest)) |
| 161 | + .andExpect(status().is(200)) |
| 162 | + .andExpect(content().json(buildResponse)); |
| 163 | + |
| 164 | + assertThat(stubCloudBuildService.findUnmatchedRequests().getRequests()).isEmpty(); |
| 165 | + } |
| 166 | + |
138 | 167 | @Test
|
139 | 168 | public void updateBuildTest() throws Exception {
|
140 | 169 | String buildId = "f0fc7c14-6035-4e5c-bda1-4848a73af5b4";
|
|
0 commit comments