github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/provider/joyent/provider_test.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package joyent_test
     5  
     6  import (
     7  	jc "github.com/juju/testing/checkers"
     8  	gc "gopkg.in/check.v1"
     9  
    10  	"github.com/juju/juju/environs/config"
    11  	"github.com/juju/juju/provider/joyent"
    12  	"github.com/juju/juju/testing"
    13  )
    14  
    15  type providerSimpleSuite struct {
    16  	testing.FakeJujuHomeSuite
    17  }
    18  
    19  var _ = gc.Suite(&providerSimpleSuite{})
    20  
    21  func (*providerSimpleSuite) TestPrepareSetsControlDir(c *gc.C) {
    22  	attrs := validAttrs()
    23  	// drop the control-dir
    24  	delete(attrs, "control-dir")
    25  	cfg, err := config.New(config.NoDefaults, attrs)
    26  	c.Assert(err, jc.ErrorIsNil)
    27  	// Make sure the the value isn't set.
    28  	_, ok := cfg.AllAttrs()["control-dir"]
    29  	c.Assert(ok, jc.IsFalse)
    30  
    31  	cfg, err = joyent.Provider.PrepareForCreateEnvironment(cfg)
    32  	c.Assert(err, jc.ErrorIsNil)
    33  	value, ok := cfg.AllAttrs()["control-dir"]
    34  	c.Assert(ok, jc.IsTrue)
    35  	c.Assert(value, gc.Matches, "[a-f0-9]{32}")
    36  }