-
Notifications
You must be signed in to change notification settings - Fork 0
/
received_request_test.go
56 lines (43 loc) · 1.38 KB
/
received_request_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package awsmocker_test
import (
"bytes"
"context"
"testing"
"github.com/aws/aws-sdk-go-v2/service/ecs"
"github.com/stretchr/testify/require"
"github.com/webdestroya/awsmocker"
)
func TestReceivedRequest_DebugDump(t *testing.T) {
origWriter := awsmocker.DebugOutputWriter
origDebugMode := awsmocker.GlobalDebugMode
t.Cleanup(func() {
awsmocker.DebugOutputWriter = origWriter
awsmocker.GlobalDebugMode = origDebugMode
})
buf := new(bytes.Buffer)
awsmocker.GlobalDebugMode = true
awsmocker.DebugOutputWriter = buf
// tables := []struct{}{}
// for _, table := range tables {
// }
info := awsmocker.Start(t, &awsmocker.MockerOptions{
SkipDefaultMocks: true,
ReturnAwsConfig: true,
// V
Mocks: []*awsmocker.MockedEndpoint{
awsmocker.Mock_Failure("ecs", "ListClusters"),
awsmocker.Mock_Failure_WithCode(403, "ecs", "ListServices", "SomeCode", "SomeMessage"),
},
})
ecsClient := ecs.NewFromConfig(*info.AwsConfig)
_, err := ecsClient.ListClusters(context.TODO(), &ecs.ListClustersInput{})
require.Error(t, err)
require.ErrorContains(t, err, "AccessDenied")
debugStr := buf.String()
buf.Reset()
require.Contains(t, debugStr, "AWSMOCKER RECEIVED REQUEST:")
require.Contains(t, debugStr, "AWSMOCKER RESPONSE:")
require.Contains(t, debugStr, "POST")
require.Contains(t, debugStr, "ecs.us-east-1.amazonaws.com")
require.Contains(t, debugStr, "ListClusters")
}