Skip to content

Commit

Permalink
fix: resolve test errors and add a new test
Browse files Browse the repository at this point in the history
  • Loading branch information
afnx committed Apr 6, 2024
1 parent cd7d550 commit 596c690
Show file tree
Hide file tree
Showing 4 changed files with 7,444 additions and 7,612 deletions.
2 changes: 0 additions & 2 deletions packages/amplify-opensearch-simulator/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
```ts

/// <reference types="node" />

import { $TSAny } from '@aws-amplify/amplify-cli-core';
import execa from 'execa';
import { GetPackageAssetPaths } from '@aws-amplify/amplify-cli-core';
Expand Down
29 changes: 29 additions & 0 deletions packages/amplify-util-mock/src/__tests__/api/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,35 @@ describe('Test Mock API methods', () => {
await expect(mockContext.print.error).toHaveBeenCalledWith('Failed to start API Mocking.');
});

it('shows error message and resolution when https enabled if SSL key and certificate paths are not provided', async () => {
ConfigOverrideManager.getInstance = jest.fn().mockReturnValue(jest.fn);
const mockContext = {
print: {
red: jest.fn(),
green: jest.fn(),
error: jest.fn(),
},
parameters: {
options: {
help: false,
},
},
input: {
argv: ['--https'],
},
amplify: {
getEnvInfo: jest.fn().mockReturnValue({ projectPath: mockProjectRoot }),
pathManager: {
getGitIgnoreFilePath: jest.fn(),
},
},
} as unknown as $TSContext;
await run(mockContext);
await expect(mockContext.print.error).toHaveBeenCalledWith(
'\nThe --https option must be followed by the path to the SSL key and the path to the SSL certificate.\n',
);
});

it('attempts to set custom port correctly', async () => {
const GRAPHQL_PORT = 8081;
const mockContext = {
Expand Down
5 changes: 5 additions & 0 deletions packages/amplify-util-mock/src/utils/get-https-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
export function getHttpsConfig(context): { sslKeyPath: string | undefined; sslCertPath: string | undefined } {
const paths: { sslKeyPath: string | undefined; sslCertPath: string | undefined } = { sslKeyPath: undefined, sslCertPath: undefined };

if (!context.input || !context.input.argv) {
return paths;
}

const argv = context.input.argv;
const httpsIndex = argv.indexOf('--https');

Expand Down
Loading

0 comments on commit 596c690

Please sign in to comment.