github.com/Pankov404/juju@v0.0.0-20150703034450-be266991dceb/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.v5"
    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.OwnerTag = "test-owner"
    35  	info.AvailabilityZone = "us-east-1a"
    36  	info.PublicAddress = "gimli.minecraft.testing.invalid"
    37  	info.PrivateAddress = "192.168.0.99"
    38  	return &info
    39  }
    40  
    41  // NewHookContext builds a jujuc.Context test double.
    42  func (s *ContextSuite) NewHookContext() (*Context, *ContextInfo) {
    43  	info := s.NewInfo()
    44  	return NewContext(s.Stub, info), info
    45  }