forked from aws/aws-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
42 lines (36 loc) · 1.01 KB
/
client.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
package awstesting
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/client"
"github.com/aws/aws-sdk-go/aws/client/metadata"
"github.com/aws/aws-sdk-go/aws/defaults"
"github.com/aws/aws-sdk-go/awstesting/mock"
)
// NewClient creates and initializes a generic service client for testing.
func NewClient(cfgs ...*aws.Config) *client.Client {
info := metadata.ClientInfo{
Endpoint: "http://endpoint",
SigningName: "",
}
def := defaults.Get()
def.Config.MergeIn(cfgs...)
return client.New(*def.Config, info, def.Handlers)
}
// NewMockClient creates and initializes a client that will connect to the
// mock server
func NewMockClient(cfgs ...*aws.Config) *client.Client {
c := mock.Session.ClientConfig("Mock", cfgs...)
svc := client.New(
*c.Config,
metadata.ClientInfo{
ServiceName: "Mock",
SigningRegion: c.SigningRegion,
Endpoint: c.Endpoint,
APIVersion: "2015-12-08",
JSONVersion: "1.1",
TargetPrefix: "MockServer",
},
c.Handlers,
)
return svc
}