Testing the API server
Jesse Meek
jesse.meek at canonical.com
Thu Sep 11 22:46:54 UTC 2014
Hi List,
The API server client tests have a new suite, serverSuite, which allow
you to test the api server methods without having to go through the api
client.
This is how to use it:
// old way
func (s *clientSuite) TestSomething(c *gc.C) {
...
// calls via api/client
err := s.APIState.Client().EnvironmentSet(args)
...
}
// new way
func (s *serverSuite) TestSomething(c *gc.C) {
...
// does not touch api/client
err := s.client.EnvironmentSet(args)
...
}
I also added PatchClientFacadeCall to api/export_test.go which allows
client side testing without touching the API server:
https://github.com/juju/juju/blob/master/api/export_test.go (see
TestShareEnvironmentExistingUser for an example)
Andrew just landed PatchFacadeCaller:
https://github.com/juju/juju/blob/master/api/base/testing/patch.go.
<https://github.com/juju/juju/blob/master/api/base/testing/patch.go>
Which is a generic Facade patcher that requires setup in export_test.go
to get access to the private facade instance (see provisioner tests for
an example). PatchClientFacadeCall can be used now, but I will be
refactoring it soon to leverage PatchFacadeCaller so we have a
consistent approach across the codebase.
Cheers,
Jess
<https://github.com/juju/juju/blob/master/api/base/testing/patch.go>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju-dev/attachments/20140912/4100b724/attachment.html>
More information about the Juju-dev
mailing list