예제 #1
0
func TestSystemWithAllMock(t *testing.T) {
	l := listener.NewMockListener()
	l.StartListen()
	e := emitter.NewEmitter(l)
	as := actions.NewActions(nil)

	// Setup actions
	addr := &actions.ActionAddress{
		NewFunc: actions.NewMockAction,
	}
	actions.RegisterAction(addr)
	actions.ActivateActions()

	// Load actions to Emitter
	e.LoadActions(as.EnabledActions)

	// BroadCast message
	e.BroadCast()

	<-e.Stopped()
	<-actions.Actions()["mock"].(*actions.MockAction).Stopped

	assert.Len(t, actions.Actions()["mock"].(*actions.MockAction).Memory, 10, "produced message size")

	actions.ClearActions()
}
예제 #2
0
func TestSystemWithDockerEvents(t *testing.T) {
	l := listener.NewMockListener()
	l.StartProduceDockerEvents()
	e := emitter.NewEmitter(l)
	as := actions.NewActions(nil).EnabledActions

	// Setup actions
	addr := &actions.ActionAddress{
		NewFunc: actions.NewMockAction,
	}
	actions.RegisterAction(addr)
	actions.ActivateActions()

	// Load actions to Emitter
	e.LoadActions(as)

	// BroadCast message
	e.BroadCast()

	<-e.Stopped()
	<-actions.Actions()["mock"].(*actions.MockAction).Stopped

	assert.Len(t, actions.Actions()["mock"].(*actions.MockAction).Memory, 10, "produced message size")

	event := actions.Actions()["mock"].(*actions.MockAction).Memory[0].(*docker.APIEvents)

	assert.Equal(t, event.From, "base:latest")

	actions.ClearActions()
}
예제 #3
0
파일: agent_test.go 프로젝트: ainoya/fune
func TestStart(t *testing.T) {
	cfg := &AgentConfig{}
	agent, _ := NewAgent(cfg)
	cfg.EnabledActions = []string{"mock"}

	agent.listener = listener.NewMockListener()
	agent.emitter = emitter.NewEmitter(agent.listener)

	agent.Start()

	<-agent.emitter.Stopped()
	<-actions.Actions()["mock"].(*actions.MockAction).Stopped

	assert.Len(t, actions.Actions()["mock"].(*actions.MockAction).Memory, 10, "produced message size")

	actions.ClearActions()
}
예제 #4
0
파일: agent.go 프로젝트: ainoya/fune
func (a *FuneAgent) activate() {
	a.listener.StartListen()

	actions.NewActions(a.listener)
	actions.EnableActions(a.cfg.EnabledActions)
	actions.ApplyConfig(a.cfg.ActionsConfig)
	actions.ActivateActions()
	a.emitter.LoadActions(actions.Actions())
}