Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(cli): "cdk context" is broken #10751

Merged
merged 1 commit into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/aws-cdk/lib/commands/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function listContext(context: any) {
function invalidateContext(context: Context, key: string) {
const i = parseInt(key, 10);
if (`${i}` === key) {
// Twas a number and we fully parsed it.
// was a number and we fully parsed it.
key = keyByNumber(context, i);
}

Expand All @@ -107,7 +107,7 @@ function keyByNumber(context: any, n: number) {
* Return enumerated keys in a definitive order
*/
function contextKeys(context: Context): [number, string][] {
const keys = context.keys;
const keys = Object.keys(context);
keys.sort();
return enumerate1(keys);
}
Expand Down
17 changes: 5 additions & 12 deletions packages/aws-cdk/test/commands/context-command.test.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
import { realHandler } from '../../lib/commands/context';
import { Configuration } from '../../lib/settings';

test('context reset can remove a context key', async () => {
test('context list', async() => {
// GIVEN
const configuration = new Configuration();
configuration.context.set('foo', 'bar');
configuration.context.set('baz', 'quux');

expect(configuration.context.all).toEqual({
foo: 'bar',
baz: 'quux',
});

// WHEN
await realHandler({
configuration,
args: { reset: 'foo' },
args: {},
} as any);

// THEN
expect(configuration.context.all).toEqual({
baz: 'quux',
});
});

test('context reset can remove a context key using number', async () => {
test('context reset can remove a context key', async () => {
// GIVEN
const configuration = new Configuration();
configuration.context.set('foo', 'bar');
Expand All @@ -38,11 +31,11 @@ test('context reset can remove a context key using number', async () => {
// WHEN
await realHandler({
configuration,
args: { reset: '1' },
args: { reset: 'foo' },
} as any);

// THEN
expect(configuration.context.all).toEqual({
foo: 'bar',
baz: 'quux',
});
});