-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Panic when attempting to mock SelectObjectContentEventStream for unit testing #3412
Comments
Hi @thesilentg, thanks for bringing this to our attention and I do apologize for the delay in response on our end. We're investigating this behavior, and will update the issue once we have additional information on the matter. |
Fixes aws#3412 by exporting the operation's EventStream type's constructor function so it can be used to fully initialize fully when mocking out behavior for API operations with event streams.
Fixes aws#3412 by exporting the operation's EventStream type's constructor function so it can be used to fully initialize fully when mocking out behavior for API operations with event streams.
Fixes #3412 by exporting the operation's EventStream type's constructor function so it can be used to fully initialize fully when mocking out behavior for API operations with event streams.
Thanks for reporting this issue @thesilentg, and providing a detailed debug. I merged in change #3473 which exports the The constructor also takes functional arguments to configure the Reader and stream closer at the same time. return &s3.SelectObjectContentOutput{
EventStream: s3.NewSelectObjectContentEventStream(func(o *s3.SelectObjectContentEventStream) {
o.Reader = myStreamReader
o.StreamCloser = myStreamCloser
}),
} |
=== ### Service Client Updates * `service/cloud9`: Updates service API and documentation * Add ConnectionType input parameter to CreateEnvironmentEC2 endpoint. New parameter enables creation of environments with SSM connection. * `service/comprehend`: Updates service documentation * `service/ec2`: Updates service API and documentation * Introduces support for IPv6-in-IPv4 IPsec tunnels. A user can now send traffic from their on-premise IPv6 network to AWS VPCs that have IPv6 support enabled. * `service/fsx`: Updates service API and documentation * `service/iot`: Updates service API, documentation, and paginators * Audit finding suppressions: Device Defender enables customers to turn off non-compliant findings for specific resources on a per check basis. * `service/lambda`: Updates service API and examples * Support for creating Lambda Functions using 'java8.al2' and 'provided.al2' * `service/transfer`: Updates service API, documentation, and paginators * Adds security policies to control cryptographic algorithms advertised by your server, additional characters in usernames and length increase, and FIPS compliant endpoints in the US and Canada regions. * `service/workspaces`: Updates service API and documentation * Adds optional EnableWorkDocs property to WorkspaceCreationProperties in the ModifyWorkspaceCreationProperties API ### SDK Enhancements * `codegen`: Add XXX_Values functions for getting slice of API enums by type. * Fixes [#3441](#3441) by adding a new XXX_Values function for each API enum type that returns a slice of enum values, e.g `DomainStatus_Values`. * `aws/request`: Update default retry to retry "use of closed network connection" errors ([#3476](#3476)) * Fixes [#3406](#3406) ### SDK Bugs * `private/protocol/json/jsonutil`: Fixes a bug that truncated millisecond precision time in API response to seconds. ([#3474](#3474)) * Fixes [#3464](#3464) * Fixes [#3410](#3410) * `codegen`: Export event stream constructor for easier mocking ([#3473](#3473)) * Fixes [#3412](#3412) by exporting the operation's EventStream type's constructor function so it can be used to fully initialize fully when mocking out behavior for API operations with event streams. * `service/ec2`: Fix max retries with client customizations ([#3465](#3465)) * Fixes [#3374](#3374) by correcting the EC2 API client's customization for ModifyNetworkInterfaceAttribute and AssignPrivateIpAddresses operations to use the aws.Config.MaxRetries value if set. Previously the API client's customizations would ignore MaxRetries specified in the SDK's aws.Config.MaxRetries field.
Release v1.34.3 (2020-08-12) === ### Service Client Updates * `service/cloud9`: Updates service API and documentation * Add ConnectionType input parameter to CreateEnvironmentEC2 endpoint. New parameter enables creation of environments with SSM connection. * `service/comprehend`: Updates service documentation * `service/ec2`: Updates service API and documentation * Introduces support for IPv6-in-IPv4 IPsec tunnels. A user can now send traffic from their on-premise IPv6 network to AWS VPCs that have IPv6 support enabled. * `service/fsx`: Updates service API and documentation * `service/iot`: Updates service API, documentation, and paginators * Audit finding suppressions: Device Defender enables customers to turn off non-compliant findings for specific resources on a per check basis. * `service/lambda`: Updates service API and examples * Support for creating Lambda Functions using 'java8.al2' and 'provided.al2' * `service/transfer`: Updates service API, documentation, and paginators * Adds security policies to control cryptographic algorithms advertised by your server, additional characters in usernames and length increase, and FIPS compliant endpoints in the US and Canada regions. * `service/workspaces`: Updates service API and documentation * Adds optional EnableWorkDocs property to WorkspaceCreationProperties in the ModifyWorkspaceCreationProperties API ### SDK Enhancements * `codegen`: Add XXX_Values functions for getting slice of API enums by type. * Fixes [#3441](#3441) by adding a new XXX_Values function for each API enum type that returns a slice of enum values, e.g `DomainStatus_Values`. * `aws/request`: Update default retry to retry "use of closed network connection" errors ([#3476](#3476)) * Fixes [#3406](#3406) ### SDK Bugs * `private/protocol/json/jsonutil`: Fixes a bug that truncated millisecond precision time in API response to seconds. ([#3474](#3474)) * Fixes [#3464](#3464) * Fixes [#3410](#3410) * `codegen`: Export event stream constructor for easier mocking ([#3473](#3473)) * Fixes [#3412](#3412) by exporting the operation's EventStream type's constructor function so it can be used to fully initialize fully when mocking out behavior for API operations with event streams. * `service/ec2`: Fix max retries with client customizations ([#3465](#3465)) * Fixes [#3374](#3374) by correcting the EC2 API client's customization for ModifyNetworkInterfaceAttribute and AssignPrivateIpAddresses operations to use the aws.Config.MaxRetries value if set. Previously the API client's customizations would ignore MaxRetries specified in the SDK's aws.Config.MaxRetries field.
Confirm by changing [ ] to [x] below to ensure that it's a bug:
Describe the bug
I'm using
SelectObjectContent
in my code. Example below:As part of unit testing, I would like mock out the S3 client. I've created my own
fakeS3Client
which conforms to thes3iface.S3API
interface. TheSelectObjectContentWithContext
method returns a fake stream reader which satisfiesSelectObjectContentEventStreamReader
and a fake iocloser which satisfiesio.Closer
.However, when trying to run the testing code, there is a panic inside of the deferred
queryResp.EventStream.Close()
. The cleaned stack trace looks like:Diving into this code more, it appears that
SelectObjectContentEventStream
has a non-exported fielderr
which is a pointer toeventstreamapi.OnceError
. When the deferredqueryResp.EventStream.Close()
is called, it callses.err.Err()
, which panics for a niles.err
. However, there is no way to set the value of this non-exported field, or callnewSelectObjectContentEventStream
, as this is also non-exported. What is the expectation here? I see three paths forward:queryResp.EventStream.Close()
. Given the documentation for this method, this seems dangerous.recover
to catch this during unit testing. Also not ideal, as this is only necessitated because of the internal implementation details of theSelectObjectContentEventStream
, which could change at any timeSelectObjectContentEventStream
to validate thatecs.err
is non-nil before callingErr()
Version of AWS SDK for Go?
1.33.1
Version of Go (
go version
)?go version go1.14.3 darwin/amd64
The text was updated successfully, but these errors were encountered: