示例#1
0
func (s *discoverySuite) TestDiscoverLocalInitSystemMatchNone(c *gc.C) {
	s.PatchLocalDiscovery(
		service.NewDiscoveryCheck("initA", false, nil),
		service.NewDiscoveryCheck("initB", false, nil),
	)

	_, err := service.DiscoverLocalInitSystem()

	c.Check(err, jc.Satisfies, errors.IsNotFound)
}
示例#2
0
func (s *discoverySuite) TestDiscoverLocalInitSystemErrorMixed(c *gc.C) {
	failure := errors.New("<failed>")
	s.PatchLocalDiscovery(
		service.NewDiscoveryCheck("initA", false, failure),
		service.NewDiscoveryCheck("initB", false, nil),
	)

	_, err := service.DiscoverLocalInitSystem()

	c.Check(err, jc.Satisfies, errors.IsNotFound)
}
示例#3
0
func (s *discoverySuite) TestDiscoverLocalInitSystemMatchSecond(c *gc.C) {
	s.PatchLocalDiscovery(
		service.NewDiscoveryCheck("initA", false, nil),
		service.NewDiscoveryCheck("initB", true, nil),
	)

	name, err := service.DiscoverLocalInitSystem()
	c.Assert(err, jc.ErrorIsNil)

	c.Check(name, gc.Equals, "initB")
}
示例#4
0
func (s *discoverySuite) TestDiscoverLocalInitSystemMatchFirstError(c *gc.C) {
	failure := errors.New("<failed>")
	s.PatchLocalDiscovery(
		service.NewDiscoveryCheck("initA", true, failure),
		service.NewDiscoveryCheck("initB", false, nil),
	)

	name, err := service.DiscoverLocalInitSystem()
	c.Assert(err, jc.ErrorIsNil)

	c.Check(name, gc.Equals, "initA")
}