github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/worker/uniter/runner/jujuc/testing/suite.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package testing
     5  
     6  import (
     7  	"github.com/juju/testing"
     8  	gc "gopkg.in/check.v1"
     9  	"gopkg.in/juju/charm.v6-unstable"
    10  )
    11  
    12  // ContextSuite is the base suite for testing jujuc.Context-related code.
    13  type ContextSuite struct {
    14  	Stub *testing.Stub
    15  	Unit string
    16  }
    17  
    18  func (s *ContextSuite) SetUpTest(c *gc.C) {
    19  	s.Stub = &testing.Stub{}
    20  	s.Unit = "u/0"
    21  }
    22  
    23  // NewInfo builds a ContextInfo with basic default data.
    24  func (s *ContextSuite) NewInfo() *ContextInfo {
    25  	var info ContextInfo
    26  	info.Unit.Name = s.Unit
    27  	info.ConfigSettings = charm.Settings{
    28  		"empty":               nil,
    29  		"monsters":            false,
    30  		"spline-reticulation": 45.0,
    31  		"title":               "My Title",
    32  		"username":            "admin001",
    33  	}
    34  	info.AvailabilityZone = "us-east-1a"
    35  	info.PublicAddress = "gimli.minecraft.testing.invalid"
    36  	info.PrivateAddress = "192.168.0.99"
    37  	return &info
    38  }
    39  
    40  // NewHookContext builds a jujuc.Context test double.
    41  func (s *ContextSuite) NewHookContext() (*Context, *ContextInfo) {
    42  	info := s.NewInfo()
    43  	return NewContext(s.Stub, info), info
    44  }