-
Notifications
You must be signed in to change notification settings - Fork 49
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
Unable to mock S3's presignGetObject call #1238
Comments
Thanks for the report! I am able to replicate the failure. The reason it throws this exception is because MockK tries to instantiate an empty
Note: This seems to be an issue with MockK / your configuration of it rather than the SDK. I'm not too familiar with using MockK, is this enough extra information to help resolve your issue? Also, do you need to use MockK? If not, you could consider writing an interceptor to throw this exception rather than have MockK do it. |
I didn't include any configuration, and for mocking purposes, I wouldn't expect any needed. Is it not possible to include a default As to why use MockK, this function fails as well
|
@hugoncosta I can't see how you're configuring your mocks but all of the presigner methods (e.g., mockStatic("aws.sdk.kotlin.services.s3.presigners.PresignersKt") The SDK does not currently provide explicit support for any specific mocking framework. We strive to generally make our code as mockable as possible but each mocking framework will have its own set up, requirements, and likely some scenarios which cannot be mocked. We're always open to suggested improvements to our code which would improve mockability but we cannot promise 100% mockability via any specific framework. I'm resolving this issue for now. Feel free to open a new issue if you encounter any SDK-specific bugs in your testing. |
|
In light of #1396 we should re-examine this request and either provide clearer instructions for how to mock presigning operations and/or improve the mockability of presigning code. |
Describe the bug
I am unable to mock a call to the S3Client's presignGetObject function as part of a unit test.
Expected behavior
The test should run successfully.
Current behavior
The test fails with the following stacktrace
Steps to Reproduce
the function it calls is the following
Possible Solution
No response
Context
I am trying to create a unit test to ensure that if an error is thrown, it is thrown captured as I expect it. I am also facing the issue if I want to mock that the function returns some ByteStream.
AWS Kotlin SDK version used
1.0.67 (?)
Platform (JVM/JS/Native)
JVM (JDK17)
Operating System and version
macOS Sonoma 14.3.1
The text was updated successfully, but these errors were encountered: