1
// Copyright 2016 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
4
package undertaker_test
7
"github.com/juju/errors"
8
"github.com/juju/testing"
9
jc "github.com/juju/testing/checkers"
10
gc "gopkg.in/check.v1"
12
"github.com/juju/juju/worker/undertaker"
15
type ValidateSuite struct {
16
testing.IsolationSuite
19
var _ = gc.Suite(&ValidateSuite{})
21
func (*ValidateSuite) TestNilFacade(c *gc.C) {
22
config := validConfig()
24
checkInvalid(c, config, "nil Facade not valid")
27
func (*ValidateSuite) TestNilEnviron(c *gc.C) {
28
config := validConfig()
30
checkInvalid(c, config, "nil Environ not valid")
33
func validConfig() undertaker.Config {
34
return undertaker.Config{
35
Facade: &fakeFacade{},
36
Environ: &fakeEnviron{},
40
func checkInvalid(c *gc.C, config undertaker.Config, message string) {
41
check := func(err error) {
42
c.Check(err, jc.Satisfies, errors.IsNotValid)
43
c.Check(err, gc.ErrorMatches, message)
45
err := config.Validate()
48
worker, err := undertaker.NewUndertaker(config)
49
c.Check(worker, gc.IsNil)