Using an InitializeMiddleware for mocking purposes... #1357
Unanswered
marc-ostrow
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When looking at the Developer Guide and first realizing there's the ability to add Custom Middleware to a service operation's stack, I searched for using this feature for mocking purposes. I didn't find anything. Of course the Developer Guide's next section on Testing discusses the traditional approach to mocking out the SDK using Go Interfaces in Lieu of using concrete service clients, paginators, and waiter types; however, you'll notice this version of the SDK no longer has the service client sub
*iface
packages with the service client interface spelled out. In fact, closer inspection reveals each service operation API manipulates the request chain -- the operation stack -- with its own middleware, to implement the operation on the backing AWS service.So I was surprised that someone hadn't already come up with a mocking library to Mock out the SDK by using Custom InitializeMiddleware to intercept and respond to SDK requests.
When you look at the version 1 SDK, they have sub
*iface
packages having service client API interface comments making the point that said interfaces "make unit testing your code that calls out to the SDK's service client's calls easier." And more to their point: "The best way to use [said interfaces] is so the SDK's service client's calls can be stubbed out for unit testing your code with the SDK without needing to inject custom request handlers into the SDK's request pipeline." What were the hoops one had to jump through in version 1 to "inject custom request handlers into the SDK's request pipeline?"Now that adding Custom Middleware is easy, and given that they have not "[made things easier]" by providing service client sub
*iface
packages with the service client interface spelled out, I'm thinking someone would have crafted a mocking framework utilizing InitializeMiddleware by now. Hmmm.Beta Was this translation helpful? Give feedback.
All reactions