Skip to content

Commit 596c690

Browse files
committed
fix: resolve test errors and add a new test
1 parent cd7d550 commit 596c690

File tree

4 files changed

+7444
-7612
lines changed

4 files changed

+7444
-7612
lines changed

packages/amplify-opensearch-simulator/API.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
55
```ts
66

7-
/// <reference types="node" />
8-
97
import { $TSAny } from '@aws-amplify/amplify-cli-core';
108
import execa from 'execa';
119
import { GetPackageAssetPaths } from '@aws-amplify/amplify-cli-core';

packages/amplify-util-mock/src/__tests__/api/api.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,35 @@ describe('Test Mock API methods', () => {
135135
await expect(mockContext.print.error).toHaveBeenCalledWith('Failed to start API Mocking.');
136136
});
137137

138+
it('shows error message and resolution when https enabled if SSL key and certificate paths are not provided', async () => {
139+
ConfigOverrideManager.getInstance = jest.fn().mockReturnValue(jest.fn);
140+
const mockContext = {
141+
print: {
142+
red: jest.fn(),
143+
green: jest.fn(),
144+
error: jest.fn(),
145+
},
146+
parameters: {
147+
options: {
148+
help: false,
149+
},
150+
},
151+
input: {
152+
argv: ['--https'],
153+
},
154+
amplify: {
155+
getEnvInfo: jest.fn().mockReturnValue({ projectPath: mockProjectRoot }),
156+
pathManager: {
157+
getGitIgnoreFilePath: jest.fn(),
158+
},
159+
},
160+
} as unknown as $TSContext;
161+
await run(mockContext);
162+
await expect(mockContext.print.error).toHaveBeenCalledWith(
163+
'\nThe --https option must be followed by the path to the SSL key and the path to the SSL certificate.\n',
164+
);
165+
});
166+
138167
it('attempts to set custom port correctly', async () => {
139168
const GRAPHQL_PORT = 8081;
140169
const mockContext = {

packages/amplify-util-mock/src/utils/get-https-config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
export function getHttpsConfig(context): { sslKeyPath: string | undefined; sslCertPath: string | undefined } {
22
const paths: { sslKeyPath: string | undefined; sslCertPath: string | undefined } = { sslKeyPath: undefined, sslCertPath: undefined };
3+
4+
if (!context.input || !context.input.argv) {
5+
return paths;
6+
}
7+
38
const argv = context.input.argv;
49
const httpsIndex = argv.indexOf('--https');
510

0 commit comments

Comments
 (0)