github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/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 "gopkg.in/check.v1"
    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)
    24  	os.Setenv("JUJU_DATA", jujuXDGDataHome)
    25  	osenv.SetJujuXDGDataHome(jujuXDGDataHome)
    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)
    35  	c.Assert(os.Getenv("JUJU_DATA"), gc.Equals, jujuXDGDataHome)
    36  }
    37  
    38  func (s *TestingBaseSuite) TestFakeHomeReplacesEnvironment(c *gc.C) {
    39  	c.Assert(utils.Home(), gc.Not(gc.Equals), home)
    40  	c.Assert(os.Getenv("JUJU_DATA"), gc.Equals, "")
    41  }