1 回答

TA贡献1783条经验 获得超4个赞
我返回的取消引用属性是错误的方法吗?
就个人而言,我不认为这是错的。我也会这样做。但更有经验的Go开发人员也许能够在这里提供更细致入微和详细的答案。
关于恐慌,我认为问题在于您创建的模拟不会返回所有必需的信息。
您的模拟:
idpMock := mockDescribeUserPoolClient{
Response: &cidp.DescribeUserPoolClientOutput{},
Error: nil,
}
您只需创建 的“空”实例。但是,您要测试的代码确实访问了两个未定义的子代码:DescribeUserPoolClientOutput
UserPoolClient(结构引用)
ClientSecret(字符串引用)
您的验证码:
*resp.UserPoolClient.ClientSecret
所以你的模拟也需要模拟这些:
idpMock := mockDescribeUserPoolClient{
Response: &cidp.DescribeUserPoolClientOutput{
UserPoolClient: &cidp.UserPoolClientType{
ClientSecret: aws.String("example-secret")
}
},
Error: nil,
}
这应该可以解决您的恐慌。
- 1 回答
- 0 关注
- 130 浏览
添加回答
举报