FYI, a few new testing functions and a package

Tim Penhey tim.penhey at canonical.com
Fri Aug 2 02:48:00 UTC 2013


Hi folks,

Just landed are two new testing functions, and previously a new package.

Firstly, the package:

  launchpad.net/juju-core/juju/osenv

This package has no other juju-core (or other) dependencies, and is a
place where we can centralize the constants used for Juju environment
variables.  This is useful as it gives us consistency across the
codebase, and we are less likely to be hit by typos in a single place.



 testing.PatchEnvironment

This method sets the environment variable with the specified value, and
returns a function that will set it back to what it was.  Simply used in
a test like this:

defer coretesting.PatchEnvironment(osenv.JujuLxcBridge, "br0")()


  Contains checker

found in: launchpad.net/juju-core/testing/checkers

Simple string contents checker.

func (s *CheckerSuite) TestContains(c *gc.C) {
	c.Assert("foo bar baz", jc.Contains, "foo")
	c.Assert("foo bar baz", jc.Contains, "bar")
	c.Assert("foo bar baz", jc.Contains, "baz")
	c.Assert("foo bar baz", gc.Not(jc.Contains), "omg")
}

That's all for today :-)

Cheers,
Tim



More information about the Juju-dev mailing list