github.com/mwhudson/juju@v0.0.0-20160512215208-90ff01f3497f/testing/base_test.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package testing_test 5 6 import ( 7 "os" 8 9 jc "github.com/juju/testing/checkers" 10 "github.com/juju/utils" 11 gc "gopkg.in/check.v1" 12 13 "github.com/juju/juju/juju/osenv" 14 "github.com/juju/juju/testing" 15 ) 16 17 type TestingBaseSuite struct { 18 testing.BaseSuite 19 } 20 21 var _ = gc.Suite(&TestingBaseSuite{}) 22 23 func (s *TestingBaseSuite) SetUpTest(c *gc.C) { 24 err := utils.SetHome(home) 25 c.Assert(err, jc.ErrorIsNil) 26 os.Setenv("JUJU_DATA", jujuXDGDataHome) 27 osenv.SetJujuXDGDataHome(jujuXDGDataHome) 28 29 s.BaseSuite.SetUpTest(c) 30 } 31 32 func (s *TestingBaseSuite) TearDownTest(c *gc.C) { 33 s.BaseSuite.TearDownTest(c) 34 35 // Test that the environment is restored. 36 c.Assert(utils.Home(), gc.Equals, home) 37 c.Assert(os.Getenv("JUJU_DATA"), gc.Equals, jujuXDGDataHome) 38 } 39 40 func (s *TestingBaseSuite) TestFakeHomeReplacesEnvironment(c *gc.C) { 41 c.Assert(utils.Home(), gc.Not(gc.Equals), home) 42 c.Assert(os.Getenv("JUJU_DATA"), gc.Equals, "") 43 }