You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, mocks can only be defined on a per test basis. We have a service that connects to an external endpoint (elasticSearch) on startup, before the http server is started. Our service cannot start as m := mocks.NewNop("elastic") returns 204 for all requests on this mock endpoint and it thinks that elasticsearch is not available.
Is it possible to start a mock server with a definition before the actual tests run?
The text was updated successfully, but these errors were encountered:
I'm afraid that that's currently not possible.
Mock has SetDefinition() method that accepts mock definition, however definition struct is private. It actually doesn't make sense that public method accepts private structs. I see 2 solutions here:
Simply make definition and newDefinition function public.
I think you could initialise a mock in this way (not an elegant, though):
m:=mocks.NewNop("elastic")
def:=map[string]interface{}{
"elastic": map[string]interface{}{
"strategy": // ... and so on in the way you write yaml
},
}
loader:=mocks.NewLoader(m)
err:=loader.Load(def)
However I also like the idea to open the mock initialisation API, i.e. not just definition and newDefinition but also interfaces verifier, strategy and bunch of builders newXXX() for standard strategies and verifiers.
Currently, mocks can only be defined on a per test basis. We have a service that connects to an external endpoint (elasticSearch) on startup, before the http server is started. Our service cannot start as
m := mocks.NewNop("elastic")
returns 204 for all requests on this mock endpoint and it thinks that elasticsearch is not available.Is it possible to start a mock server with a definition before the actual tests run?
The text was updated successfully, but these errors were encountered: