Skip to content

Commit

Permalink
remove some inappropriate api responses, add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
mmorgantaylor committed Jan 23, 2024
1 parent a67bb4e commit 41b91e9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
22 changes: 7 additions & 15 deletions common/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/GetPipelinesResult'
403:
$ref: '#/components/responses/PermissionDenied'
404:
$ref: '#/components/responses/NotFound'
500:
$ref: '#/components/responses/ServerError'

Expand All @@ -71,10 +67,8 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Pipeline'
403:
$ref: '#/components/responses/PermissionDenied'
404:
$ref: '#/components/responses/NotFound'
400:
$ref: '#/components/responses/BadRequest'
500:
$ref: '#/components/responses/ServerError'
post:
Expand All @@ -89,7 +83,7 @@ paths:
$ref: '#/components/schemas/CreateJobRequestBody'
responses:
200:
description: Success
description: Request is complete (succeeded or failed)
content:
application/json:
schema:
Expand Down Expand Up @@ -125,10 +119,8 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/GetJobsResponse'
403:
$ref: '#/components/responses/PermissionDenied'
404:
$ref: '#/components/responses/NotFound'
400:
$ref: '#/components/responses/BadRequest'
500:
$ref: '#/components/responses/ServerError'

Expand Down Expand Up @@ -161,13 +153,13 @@ paths:
operationId: getJob
responses:
200:
description: TspsJob is complete (succeeded or failed)
description: Job is complete (succeeded or failed)
content:
application/json:
schema:
$ref: '#/components/schemas/JobReport'
202:
description: TspsJob is running
description: Job is running
headers:
Retry-After:
description: >-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ void getPipelineCaseInsensitive() throws Exception {
assertEquals(pipelineIdEnum.getValue(), response.getPipelineId());
}

@Test
void getPipeline_badPipeline() throws Exception {
String pipelineIdString = "bad-pipeline-id";

mockMvc
.perform(get("/api/pipelines/v1alpha1/" + pipelineIdString))
.andExpect(status().isBadRequest())
.andExpect(
result ->
assertTrue(result.getResolvedException() instanceof InvalidPipelineException));
}

@Test
void testCreateJobImputationPipelineRunning() throws Exception {
String pipelineIdString = PipelinesEnum.IMPUTATION.getValue();
Expand Down Expand Up @@ -362,4 +374,16 @@ void testGetPipelineJobs() throws Exception {
},
response.getResults().stream().map(ApiJobReport::getStatus).toArray());
}

@Test
void testGetPipelineJobs_badPipeline() throws Exception {
String pipelineIdString = "bad-pipeline-id";

mockMvc
.perform(get(String.format("/api/pipelines/v1alpha1/%s/jobs", pipelineIdString)))
.andExpect(status().isBadRequest())
.andExpect(
result ->
assertTrue(result.getResolvedException() instanceof InvalidPipelineException));
}
}

0 comments on commit 41b91e9

Please sign in to comment.