github.com/rogpeppe/juju@v0.0.0-20140613142852-6337964b789e/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  	"github.com/juju/utils"
    10  	gc "launchpad.net/gocheck"
    11  
    12  	"github.com/juju/juju/juju/osenv"
    13  	"github.com/juju/juju/testing"
    14  )
    15  
    16  type TestingBaseSuite struct {
    17  	testing.BaseSuite
    18  }
    19  
    20  var _ = gc.Suite(&TestingBaseSuite{})
    21  
    22  func (s *TestingBaseSuite) SetUpTest(c *gc.C) {
    23  	utils.SetHome("/home/eric")
    24  	os.Setenv("JUJU_HOME", "/home/eric/juju")
    25  	osenv.SetJujuHome("/home/eric/juju")
    26  
    27  	s.BaseSuite.SetUpTest(c)
    28  }
    29  
    30  func (s *TestingBaseSuite) TearDownTest(c *gc.C) {
    31  	s.BaseSuite.TearDownTest(c)
    32  
    33  	// Test that the environment is restored.
    34  	c.Assert(utils.Home(), gc.Equals, "/home/eric")
    35  	c.Assert(os.Getenv("JUJU_HOME"), gc.Equals, "/home/eric/juju")
    36  }
    37  
    38  func (s *TestingBaseSuite) TestFakeHomeReplacesEnvironment(c *gc.C) {
    39  	c.Assert(utils.Home(), gc.Not(gc.Equals), "/home/eric")
    40  	c.Assert(os.Getenv("JUJU_HOME"), gc.Equals, "")
    41  }