mirror of
https://github.com/mariocandela/beelzebub.git
synced 2025-07-01 18:47:26 -04:00
Feature: non-blocking tracer, changed license (#57)
* refactor tracer, introduce worker to avoid un-blocker trace strategy * fixed unit test and refactor dockerFile * buffered events chan * refactor yaml API core, initial web hook tracing implementations * added banner * changed license from GPL 3 to MIT * Edit readme
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
package tracer
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestInit(t *testing.T) {
|
||||
@ -15,23 +17,56 @@ func TestInit(t *testing.T) {
|
||||
|
||||
func TestTraceEvent(t *testing.T) {
|
||||
eventCalled := Event{}
|
||||
var wg sync.WaitGroup
|
||||
|
||||
mockStrategy := func(event Event) {
|
||||
defer wg.Done()
|
||||
|
||||
eventCalled = event
|
||||
}
|
||||
|
||||
tracer := Init(mockStrategy)
|
||||
|
||||
wg.Add(1)
|
||||
tracer.TraceEvent(Event{
|
||||
ID: "mockID",
|
||||
Protocol: HTTP.String(),
|
||||
Status: Stateless.String(),
|
||||
})
|
||||
wg.Wait()
|
||||
|
||||
assert.NotNil(t, eventCalled.ID)
|
||||
assert.Equal(t, eventCalled.ID, "mockID")
|
||||
assert.Equal(t, eventCalled.Protocol, HTTP.String())
|
||||
assert.Equal(t, eventCalled.Status, Stateless.String())
|
||||
assert.Equal(t, "mockID", eventCalled.ID)
|
||||
assert.Equal(t, HTTP.String(), eventCalled.Protocol)
|
||||
assert.Equal(t, Stateless.String(), eventCalled.Status)
|
||||
}
|
||||
|
||||
func TestSetStrategy(t *testing.T) {
|
||||
eventCalled := Event{}
|
||||
var wg sync.WaitGroup
|
||||
|
||||
mockStrategy := func(event Event) {
|
||||
defer wg.Done()
|
||||
|
||||
eventCalled = event
|
||||
}
|
||||
|
||||
tracer := Init(mockStrategy)
|
||||
|
||||
tracer.setStrategy(mockStrategy)
|
||||
|
||||
wg.Add(1)
|
||||
tracer.TraceEvent(Event{
|
||||
ID: "mockID",
|
||||
Protocol: HTTP.String(),
|
||||
Status: Stateless.String(),
|
||||
})
|
||||
wg.Wait()
|
||||
|
||||
assert.NotNil(t, eventCalled.ID)
|
||||
assert.Equal(t, "mockID", eventCalled.ID)
|
||||
assert.Equal(t, HTTP.String(), eventCalled.Protocol)
|
||||
assert.Equal(t, Stateless.String(), eventCalled.Status)
|
||||
}
|
||||
|
||||
func TestStringStatus(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user