mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
43 lines
1.0 KiB
Go
43 lines
1.0 KiB
Go
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
|
|
}
|