Example #1
0
var validateTests = []struct {
	info hook.Info
	err  string
}{
	{
		hook.Info{Kind: hook.RelationJoined},
		`"relation-joined" hook requires a remote unit`,
	}, {
		hook.Info{Kind: hook.RelationChanged},
		`"relation-changed" hook requires a remote unit`,
	}, {
		hook.Info{Kind: hook.RelationDeparted},
		`"relation-departed" hook requires a remote unit`,
	}, {
		hook.Info{Kind: hook.Kind("grok")},
		`unknown hook kind "grok"`,
	},
	{hook.Info{Kind: hook.Install}, ""},
	{hook.Info{Kind: hook.Start}, ""},
	{hook.Info{Kind: hook.ConfigChanged}, ""},
	{hook.Info{Kind: hook.UpgradeCharm}, ""},
	{hook.Info{Kind: hook.Stop}, ""},
	{hook.Info{Kind: hook.RelationJoined, RemoteUnit: "x"}, ""},
	{hook.Info{Kind: hook.RelationChanged, RemoteUnit: "x"}, ""},
	{hook.Info{Kind: hook.RelationDeparted, RemoteUnit: "x"}, ""},
	{hook.Info{Kind: hook.RelationBroken}, ""},
}

func (s *InfoSuite) TestValidate(c *C) {
	for i, t := range validateTests {
Example #2
0
			OpStep: uniter.Pending,
		},
		err: `missing charm URL`,
	}, {
		st: uniter.State{
			Op:       uniter.Install,
			OpStep:   uniter.Pending,
			CharmURL: stcurl,
		},
	},
	// RunHook operation.
	{
		st: uniter.State{
			Op:     uniter.RunHook,
			OpStep: uniter.Pending,
			Hook:   &hook.Info{Kind: hook.Kind("machine-exploded")},
		},
		err: `unknown hook kind "machine-exploded"`,
	}, {
		st: uniter.State{
			Op:     uniter.RunHook,
			OpStep: uniter.Pending,
			Hook:   &hook.Info{Kind: hook.RelationJoined},
		},
		err: `"relation-joined" hook requires a remote unit`,
	}, {
		st: uniter.State{
			Op:       uniter.RunHook,
			OpStep:   uniter.Pending,
			Hook:     &hook.Info{Kind: hook.ConfigChanged},
			CharmURL: stcurl,