At first, I tried to follow the "generator" pattern that had already
been implemented for the order and secret objects. These generators look
like:
import (
"github.com/jetstack/cert-manager/test/unit/listers"
)
fake := listers.FakeSecretListerFrom(listers.NewFakeSecretLister(),
listers.SetFakeSecretNamespaceListerGet(nil, errors.New("not found")),
)
The major issue I was finding with this approach is that you cannot
enforce any behavior with these fakes: no way to check (or prevent)
unwanted called, no way to check that the correct namespace was used for
the call:
fake.Secrets("default").Get("secret-1")
which is annoying; I want to be able to check every input, output and
call numbers made to the mocked function.
So I propose a gomock-like approach. I could not use mockgen due to the
fact that (again) client-go is overly nested, which means I would have
to use quite a lot of glue code in order to use mockgen-generated mocks.
Signed-off-by: Maël Valais <mael@vls.dev>