github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/worker/introspection/script_test.go (about)

     1  // Copyright 2016 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package introspection
     5  
     6  import (
     7  	"io/ioutil"
     8  	"runtime"
     9  
    10  	"github.com/juju/testing"
    11  	jc "github.com/juju/testing/checkers"
    12  	gc "gopkg.in/check.v1"
    13  )
    14  
    15  type profileSuite struct {
    16  	testing.IsolationSuite
    17  }
    18  
    19  var _ = gc.Suite(&profileSuite{})
    20  
    21  func (*profileSuite) TestProfileFilename(c *gc.C) {
    22  	c.Assert(profileFilename(), gc.Equals, "/etc/profile.d/juju-introspection.sh")
    23  }
    24  
    25  func (*profileSuite) TestNonLinux(c *gc.C) {
    26  	if runtime.GOOS == "linux" {
    27  		c.Skip("testing non-linux")
    28  	}
    29  	err := WriteProfileFunctions()
    30  	c.Assert(err, jc.ErrorIsNil)
    31  }
    32  
    33  func (s *profileSuite) TestLinux(c *gc.C) {
    34  	if runtime.GOOS != "linux" {
    35  		c.Skip("testing linux")
    36  	}
    37  	dir := c.MkDir()
    38  	s.PatchValue(&profileDir, dir)
    39  	err := WriteProfileFunctions()
    40  	c.Assert(err, jc.ErrorIsNil)
    41  
    42  	content, err := ioutil.ReadFile(profileFilename())
    43  	c.Assert(err, jc.ErrorIsNil)
    44  	c.Assert(string(content), gc.Equals, bashFuncs)
    45  }