aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorAnthony Chang <anthony20093@gmail.com>2024-01-12 18:32:31 -0500
committerCecylia Bocovich <cohosh@torproject.org>2024-01-22 13:10:56 -0500
commitf3b062ddb2f1bc152702f562b0c4b2ed6db4d1aa (patch)
tree197ab9ca6483e7767b008f1b696d38ff9dd4881c /client
parent8fb17de1529281d30f1eb3c9d746de70673337fa (diff)
downloadsnowflake-f3b062ddb2f1bc152702f562b0c4b2ed6db4d1aa.tar.gz
snowflake-f3b062ddb2f1bc152702f562b0c4b2ed6db4d1aa.zip
Add mocks and interfaces for testing SQS rendezvous
Co-authored-by: Michael Pu <michael.pu@uwaterloo.ca>
Diffstat (limited to 'client')
-rw-r--r--client/lib/rendezvous_sqs.go3
-rw-r--r--client/lib/sqs_test.go30
2 files changed, 32 insertions, 1 deletions
diff --git a/client/lib/rendezvous_sqs.go b/client/lib/rendezvous_sqs.go
index 0ef4df4..89f5694 100644
--- a/client/lib/rendezvous_sqs.go
+++ b/client/lib/rendezvous_sqs.go
@@ -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
}
diff --git a/client/lib/sqs_test.go b/client/lib/sqs_test.go
new file mode 100644
index 0000000..02da33f
--- /dev/null
+++ b/client/lib/sqs_test.go
@@ -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"),
+ })
+ })
+}