示例#1
0
	}
}

func (c *TestSink) Identifier() string        { return c.identifier }
func (c *TestSink) ShouldReceiveErrors() bool { return true }
func (c *TestSink) Emit() instrumentation.Context {
	return instrumentation.Context{}
}

var _ = Describe("GroupedSink", func() {
	var fakeTimeProvider *faketimeprovider.FakeTimeProvider
	var groupedSinks *groupedsinks.GroupedSinks
	var inputChan, errorChan chan *logmessage.Message

	BeforeEach(func() {
		fakeTimeProvider = faketimeprovider.New(time.Now())
		groupedSinks = groupedsinks.NewGroupedSinks()
		inputChan = make(chan *logmessage.Message)
		errorChan = make(chan *logmessage.Message)

	})

	Describe("BroadCast", func() {
		It("should send message to all registered sinks that match the appId", func(done Done) {
			appId := "123"
			appSink := syslog.NewSyslogSink("123", "url", loggertesthelper.Logger(), DummySyslogWriter{}, errorChan)
			otherInputChan := make(chan *logmessage.Message)
			groupedSinks.Register(otherInputChan, appSink)

			appId = "789"
			appSink = syslog.NewSyslogSink(appId, "url", loggertesthelper.Logger(), DummySyslogWriter{}, errorChan)
		timeProvider      *faketimeprovider.FakeTimeProvider
		messageBus        *fakeyagnats.FakeYagnats
		logger            *fakelogger.FakeLogger
		conf              *config.Config
		freshByTime       time.Time
		usageTracker      *fakeusagetracker.FakeUsageTracker
		metricsAccountant *fakemetricsaccountant.FakeMetricsAccountant
	)

	BeforeEach(func() {
		var err error
		conf, err = config.DefaultConfig()

		Ω(err).ShouldNot(HaveOccurred())

		timeProvider = faketimeprovider.New(time.Unix(100, 0))
		timeProvider.ProvideFakeChannels = true

		freshByTime = time.Unix(int64(100+conf.ActualFreshnessTTL()), 0)

		dea = NewDeaFixture()
		app = NewAppFixture()
		anotherApp = NewAppFixture()
		anotherApp.DeaGuid = app.DeaGuid

		storeAdapter = fakestoreadapter.New()
		store = storepackage.NewStore(conf, storeAdapter, fakelogger.NewFakeLogger())
		messageBus = fakeyagnats.New()
		logger = fakelogger.NewFakeLogger()

		usageTracker = fakeusagetracker.New()