-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(lib-dynamodb): make command middleware useable, turn marshalling …
…into middleware
- Loading branch information
Showing
17 changed files
with
498 additions
and
262 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
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
57 changes: 57 additions & 0 deletions
57
lib/lib-dynamodb/src/baseCommand/DynamoDBDocumentClientCommand.spec.ts
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,57 @@ | ||
import { Handler, MiddlewareStack } from "@aws-sdk/types"; | ||
|
||
import { KeyNode } from "../commands/utils"; | ||
import { DynamoDBDocumentClientCommand } from "./DynamoDBDocumentClientCommand"; | ||
|
||
class AnyCommand extends DynamoDBDocumentClientCommand<{}, {}, {}, {}, {}> { | ||
public middlewareStack: MiddlewareStack<{}, {}>; | ||
public input: {}; | ||
protected inputKeyNodes: KeyNode[] = []; | ||
protected outputKeyNodes: KeyNode[] = []; | ||
|
||
public argCaptor: [Function, object][] = []; | ||
|
||
protected readonly clientCommand = { | ||
middlewareStack: { | ||
argCaptor: this.argCaptor, | ||
add(fn, config) { | ||
this.argCaptor.push([fn, config]); | ||
}, | ||
}, | ||
} as any; | ||
protected readonly clientCommandName = "AnyCommand"; | ||
|
||
public constructor() { | ||
super(); | ||
} | ||
|
||
public resolveMiddleware(clientStack: MiddlewareStack<any, any>, configuration: {}, options: any): Handler<{}, {}> { | ||
this.addMarshallingMiddleware({} as any); | ||
return null as any; | ||
} | ||
} | ||
|
||
describe("DynamoDBDocumentClientCommand", () => { | ||
it("should not allow usage of the default middlewareStack", () => { | ||
const command = new AnyCommand(); | ||
command.resolveMiddleware(null as any, null as any, null as any); | ||
{ | ||
const [middleware, options] = command.argCaptor[0]; | ||
expect(middleware.toString()).toContain(`marshallInput`); | ||
expect(options).toEqual({ | ||
name: "AnyCommandMarshall", | ||
override: true, | ||
step: "initialize", | ||
}); | ||
} | ||
{ | ||
const [middleware, options] = command.argCaptor[1]; | ||
expect(middleware.toString()).toContain(`unmarshallOutput`); | ||
expect(options).toEqual({ | ||
name: "AnyCommandUnmarshall", | ||
override: true, | ||
step: "deserialize", | ||
}); | ||
} | ||
}); | ||
}); |
Oops, something went wrong.