Skip to content

Commit

Permalink
change the version missing response
Browse files Browse the repository at this point in the history
  • Loading branch information
jloleysens committed Apr 3, 2023
1 parent 5388234 commit e723e06
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ describe('Versioned route', () => {
).resolves.toEqual(
expect.objectContaining({
payload:
'No version "999" available for [post] [/test/{id}]. Available versions are: "none"',
'No version "999" available for [post] [/test/{id}]. Available versions are: <none>',
status: 406,
})
);
Expand All @@ -212,7 +212,7 @@ describe('Versioned route', () => {
handler!({} as any, createRequest({ version: undefined }), responseFactory)
).resolves.toEqual({
options: {},
payload: `Version expected at [post] [/test/{id}]. Please specify a version using the "${ELASTIC_HTTP_VERSION_HEADER}" header. Available versions are: "1"`,
payload: `Version expected at [post] [/test/{id}]. Please specify a version using the "${ELASTIC_HTTP_VERSION_HEADER}" header. Available versions are: [1]`,
status: 406,
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ export class CoreVersionedRoute implements VersionedRoute {
}

private getAvailableVersionsMessage(): string {
return `Available versions are: "${[...this.handlers.keys()].join(',') || 'none'}"`;
const versions = [...this.handlers.keys()];
return `Available versions are: ${
versions.length ? '[' + [...versions].join(', ') + ']' : '<none>'
}`;
}

/** This is where we must implement the versioned spec once it is available */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ describe('Routing versioned requests', () => {
.then(({ body }) => body)
).resolves.toEqual(
expect.objectContaining({
message:
'Version expected at [get] [/my-path]. Please specify a version using the "elastic-api-version" header. Available versions are: "1,2"',
message: expect.stringMatching(/Version expected at/),
})
);
});
Expand Down

0 comments on commit e723e06

Please sign in to comment.