github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/tools/lxdclient/utils_test.go (about)

     1  // Copyright 2016 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  // +build go1.3
     5  
     6  package lxdclient_test
     7  
     8  import (
     9  	"errors"
    10  
    11  	"github.com/juju/testing"
    12  	jc "github.com/juju/testing/checkers"
    13  	gc "gopkg.in/check.v1"
    14  
    15  	"github.com/juju/juju/tools/lxdclient"
    16  )
    17  
    18  var (
    19  	_ = gc.Suite(&utilsSuite{})
    20  )
    21  
    22  type utilsSuite struct {
    23  	lxdclient.BaseSuite
    24  }
    25  
    26  func (s *utilsSuite) TestEnableHTTPSListener(c *gc.C) {
    27  	var client mockConfigSetter
    28  	err := lxdclient.EnableHTTPSListener(&client)
    29  	c.Assert(err, jc.ErrorIsNil)
    30  	client.CheckCall(c, 0, "SetConfig", "core.https_address", "[::]")
    31  }
    32  
    33  func (s *utilsSuite) TestEnableHTTPSListenerError(c *gc.C) {
    34  	var client mockConfigSetter
    35  	client.SetErrors(errors.New("uh oh"))
    36  	err := lxdclient.EnableHTTPSListener(&client)
    37  	c.Assert(err, gc.ErrorMatches, "uh oh")
    38  }
    39  
    40  type mockConfigSetter struct {
    41  	testing.Stub
    42  }
    43  
    44  func (m *mockConfigSetter) SetConfig(k, v string) error {
    45  	m.MethodCall(m, "SetConfig", k, v)
    46  	return m.NextErr()
    47  }