mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 11:11:30 -04:00
Add mocks and interfaces for testing SQS rendezvous
Co-authored-by: Michael Pu <michael.pu@uwaterloo.ca>
This commit is contained in:
parent
8fb17de152
commit
f3b062ddb2
7 changed files with 262 additions and 4 deletions
|
@ -15,12 +15,13 @@ import (
|
|||
"github.com/aws/aws-sdk-go-v2/credentials"
|
||||
"github.com/aws/aws-sdk-go-v2/service/sqs"
|
||||
"github.com/aws/aws-sdk-go-v2/service/sqs/types"
|
||||
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/sqsclient"
|
||||
)
|
||||
|
||||
type sqsRendezvous struct {
|
||||
transport http.RoundTripper
|
||||
sqsClientID string
|
||||
sqsClient *sqs.Client
|
||||
sqsClient sqsclient.SQSClient
|
||||
sqsURL *url.URL
|
||||
}
|
||||
|
||||
|
|
30
client/lib/sqs_test.go
Normal file
30
client/lib/sqs_test.go
Normal file
|
@ -0,0 +1,30 @@
|
|||
package snowflake_client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/service/sqs"
|
||||
"github.com/golang/mock/gomock"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
"gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/v2/common/sqsclient"
|
||||
)
|
||||
|
||||
func TestExample(t *testing.T) {
|
||||
Convey("Test Example 1", t, func() {
|
||||
ctrl := gomock.NewController(t)
|
||||
mockSqsClient := sqsclient.NewMockSQSClient(ctrl)
|
||||
mockSqsClient.EXPECT().GetQueueUrl(gomock.Any(), gomock.Any()).Return(&sqs.GetQueueUrlOutput{
|
||||
QueueUrl: aws.String("https://wwww.google.com"),
|
||||
}, nil)
|
||||
|
||||
output, err := mockSqsClient.GetQueueUrl(context.TODO(), &sqs.GetQueueUrlInput{
|
||||
QueueName: aws.String("testing"),
|
||||
})
|
||||
ShouldBeNil(err)
|
||||
ShouldEqual(output, sqs.GetQueueUrlOutput{
|
||||
QueueUrl: aws.String("https://wwww.google.com"),
|
||||
})
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue