I'm using latest v1.17.15 aws-sdk-go-v2 for acmpca but this doesn't have acmpcaiface interfaces. Now how to mock these acmpca api for my unit testing? Please help me to mock the interfaces. Currently I'm using IssueCertificate() and GetCertificate() in my code which needs to be mocked for unit testing.
Asked
Active
Viewed 237 times
0
-
Please provide enough code so others can better understand or reproduce the problem. – Community Sep 16 '22 at 00:49
1 Answers
1
You don't need acmpcaiface
for unit testing. You can simply mock the operations you use in your use case. Amazon has already provided an excellent document on how to mock client operations.
I usually create the interfaces on my own. For example -
// You can use AWSCertificateOperations interface instead on concrete acmpca
// client in your code.
type AWSCertificateOperations interface {
IssueCertificate(params...) returns..
GetCertificate(params...) return...
}
type mockAWSCertificateOperations struct {}
func (m *mockAWSCertificateOperations) IssueCertificate(params...) returns... {
// whatever mock logic you want to have
}
func (m *mockAWSCertificateOperations) GetCertificate(params...) returns... {
// whatever mock logic you want to have
}

awwwd
- 121
- 2
- 9