-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding the most basic tests to the cli
- Loading branch information
Showing
14 changed files
with
249 additions
and
409 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
node_modules | ||
.vscode/ | ||
# ignore codecoverage output | ||
coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/no-non-null-assertion */ | ||
import { SSM as RealSSM } from 'aws-sdk'; | ||
type SSMMOCKS = Record<string, any> | ||
let ssmMocks = {} as SSMMOCKS; | ||
|
||
type Dispatch = (response: Promise<any>, callback?: Function) => { promise: () => Promise<any> } | any | ||
const dispatch: Dispatch = (response, callback?: Function) => { | ||
if (!callback) { | ||
return { | ||
promise: () => response, | ||
} | ||
} | ||
return response.then((result: RealSSM.DescribeParametersResult) => callback(null, result)).catch((err: Error) => callback(err, null)); | ||
} | ||
|
||
const handleDescribeParameters = async (props: RealSSM.DescribeParametersRequest): Promise<Record<string, any>> => { | ||
const [filter] = props.ParameterFilters!; | ||
|
||
if (filter && filter.Key in ssmMocks) { | ||
return ssmMocks[filter.Key]; | ||
} else { | ||
return {} | ||
} | ||
}; | ||
|
||
export default class SSM { | ||
static __setResponseForMethods(mock: SSMMOCKS) { | ||
ssmMocks = { ...ssmMocks, ...mock }; | ||
} | ||
|
||
static __showMockedPayloads() { | ||
return { ...ssmMocks }; | ||
} | ||
|
||
describeParameters(props: RealSSM.DescribeParametersRequest, callback?: Function) { | ||
const promise = handleDescribeParameters(props); | ||
|
||
return dispatch(promise, callback); | ||
|
||
} | ||
} |
Oops, something went wrong.