예제 #1
0
파일: fixture_test.go 프로젝트: kat-co/juju
// RunDumb starts a DumbWorkers inside a fresh Context and supplies it
// to a test func.
func (fix Fixture) RunDumb(c *gc.C, test func(Context, *workers.DumbWorkers)) {
	fix.Run(c, func(ctx Context) {
		dw, err := workers.NewDumbWorkers(workers.DumbConfig{
			Factory: ctx.Factory(),
			Logger:  loggo.GetLogger("test"),
		})
		c.Assert(err, jc.ErrorIsNil)
		defer workertest.DirtyKill(c, dw)
		test(ctx, dw)
	})
}
예제 #2
0
파일: fixture_test.go 프로젝트: kat-co/juju
// FailDumb verifies that a DumbWorkers cannot start successfully, and
// checks that the returned error matches.
func (fix Fixture) FailDumb(c *gc.C, match string) {
	fix.Run(c, func(ctx Context) {
		dw, err := workers.NewDumbWorkers(workers.DumbConfig{
			Factory: ctx.Factory(),
			Logger:  loggo.GetLogger("test"),
		})
		if !c.Check(dw, gc.IsNil) {
			workertest.DirtyKill(c, dw)
		}
		c.Check(err, gc.ErrorMatches, match)
	})
}
예제 #3
0
파일: dumb_test.go 프로젝트: bac/juju
func (*DumbWorkersSuite) TestValidateMissingFactory(c *gc.C) {
	config := workers.DumbConfig{
		Logger: loggo.GetLogger("test"),
	}
	check := func(err error) {
		c.Check(err, gc.ErrorMatches, "nil Factory not valid")
		c.Check(err, jc.Satisfies, errors.IsNotValid)
	}

	check(config.Validate())
	w, err := workers.NewDumbWorkers(config)
	if !c.Check(w, gc.IsNil) {
		workertest.CleanKill(c, w)
	}
	check(err)
}
예제 #4
0
파일: dumb_test.go 프로젝트: bac/juju
func (*DumbWorkersSuite) TestValidateUninitializedLogger(c *gc.C) {
	config := workers.DumbConfig{
		Factory: struct{ workers.Factory }{},
	}
	check := func(err error) {
		c.Check(err, gc.ErrorMatches, "uninitialized Logger not valid")
		c.Check(err, jc.Satisfies, errors.IsNotValid)
	}

	check(config.Validate())
	w, err := workers.NewDumbWorkers(config)
	if !c.Check(w, gc.IsNil) {
		workertest.CleanKill(c, w)
	}
	check(err)
}