A util suite is a struct which provides specific setup and teardown behavior as well as useful variables and functions to write unit tests suites with.
There are several util suites, among which:
- /testing.BaseSuite (testing/base.go)
- /testing.FakeHomeSuite (testing/environ.go)
- /testing.FakeJujuHomeSuite (testing/environ.go)
- /juju/testing.JujuConnSuite (juju/testing/conn.go)
The last three have the BaseSuite functionality included through composition. The BaseSuite isolates a user’s home directory from accidental modification (by setting $HOME to “”) and errors if there is an attempt to do outgoing HTTP access. It also clears the relevant $JUJU_* environment variables. The BaseSuite is also composed of the core LoggingSuite, and also LoggingSuite from github.com/juju/testing, which brings in the CleanupSuite from the same. The CleanupSuite has functionality around patching environment variables and normal variables for the duration of a test. It also provides a clean-up stack called when the test teardown happens.
If you need additional functionality, you can embed one of the suites below:
FakeHomeSuite: creates a fake home directory with ~/.ssh and fake ssh keys.
FakeJujuHomeSuite: as above but also sets up a ~/.config/juju with a fake model.
JujuConnSuite: (TO BE DEPRECATED) Simulates a controller and an API server as well as a database. Quite heavy weight. Can be useful in that it simulates a Juju environment as closely as possible.
Last updated 3 months ago.