我正在使用两个 AWS 服务,Glue 和 DynamoDB,并且这两个服务具有相同的方法名称,CreateTable因此在模拟这些服务时,我收到CreateTable is ambiguous错误。
胶水:CreateTable https://docs.aws.amazon.com/sdk-for-go/api/service/glue/#Glue.CreateTable
DynamoDB:CreateTable https://docs.aws.amazon.com/sdk-for-go/api/service/dynamodb/#DynamoDB.CreateTable
有什么办法可以解决这个问题吗?
代码:
type UpdateWorkflow struct {
glueIface glueiface.GlueAPI
dbIface dynamodbiface.DynamoDBAPI
tableName string
}
func NewUpdateWorkflow(tableName string) *UpdateWorkflow {
sess := sessions.NewSession()
return &UpdateWorkflow{
dbIface: dynamodb.New(sess),
glueIface: glue.New(sess),
tableName: tableName,
}
}
单元测试:
// MockUpdateWorkflow is a mock implementation of gluetestutils and dynamodb service
type MockUpdateWorkflow struct {
glueiface.GlueAPI
dynamodbiface.DynamoDBAPI
mock.Mock
}
func setup() (*UpdateWorkflow, *MockUpdateWorkflow) {
mockClient := new(MockUpdateWorkflow)
mockServices := &UpdateWorkflow{
glueIface: mockClient,
dbIface: mockClient,
tableName: mockTableName,
}
return mockServices, mockClient
}
慕标琳琳
相关分类