Remove neko entirely
This commit is contained in:
parent
9c42aea28c
commit
f9250e8e39
115
agent_test.go
115
agent_test.go
|
@ -6,74 +6,75 @@ import (
|
||||||
"github.com/influxdb/tivan/plugins"
|
"github.com/influxdb/tivan/plugins"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/vektra/cypress"
|
"github.com/vektra/cypress"
|
||||||
"github.com/vektra/neko"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAgent(t *testing.T) {
|
func TestAgent_DrivesMetrics(t *testing.T) {
|
||||||
n := neko.Start(t)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
plugin plugins.MockPlugin
|
plugin plugins.MockPlugin
|
||||||
metrics MockMetrics
|
metrics MockMetrics
|
||||||
)
|
)
|
||||||
|
|
||||||
n.CheckMock(&plugin.Mock)
|
defer plugin.AssertExpectations(t)
|
||||||
n.CheckMock(&metrics.Mock)
|
defer metrics.AssertExpectations(t)
|
||||||
|
|
||||||
n.It("drives the plugins and sends them to the metrics", func() {
|
a := &Agent{
|
||||||
a := &Agent{
|
plugins: []plugins.Plugin{&plugin},
|
||||||
plugins: []plugins.Plugin{&plugin},
|
metrics: &metrics,
|
||||||
metrics: &metrics,
|
Config: &Config{},
|
||||||
Config: &Config{},
|
}
|
||||||
}
|
|
||||||
|
|
||||||
m1 := cypress.Metric()
|
m1 := cypress.Metric()
|
||||||
m1.Add("name", "foo")
|
m1.Add("name", "foo")
|
||||||
m1.Add("value", 1.2)
|
m1.Add("value", 1.2)
|
||||||
|
|
||||||
m2 := cypress.Metric()
|
m2 := cypress.Metric()
|
||||||
m2.Add("name", "bar")
|
m2.Add("name", "bar")
|
||||||
m2.Add("value", 888)
|
m2.Add("value", 888)
|
||||||
|
|
||||||
msgs := []*cypress.Message{m1, m2}
|
msgs := []*cypress.Message{m1, m2}
|
||||||
|
|
||||||
plugin.On("Read").Return(msgs, nil)
|
plugin.On("Read").Return(msgs, nil)
|
||||||
metrics.On("Receive", m1).Return(nil)
|
metrics.On("Receive", m1).Return(nil)
|
||||||
metrics.On("Receive", m2).Return(nil)
|
metrics.On("Receive", m2).Return(nil)
|
||||||
|
|
||||||
err := a.crank()
|
err := a.crank()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
})
|
}
|
||||||
|
|
||||||
n.It("applies tags as the messages pass through", func() {
|
func TestAgent_AppliesTags(t *testing.T) {
|
||||||
a := &Agent{
|
var (
|
||||||
plugins: []plugins.Plugin{&plugin},
|
plugin plugins.MockPlugin
|
||||||
metrics: &metrics,
|
metrics MockMetrics
|
||||||
Config: &Config{
|
)
|
||||||
Tags: map[string]string{
|
|
||||||
"dc": "us-west-1",
|
defer plugin.AssertExpectations(t)
|
||||||
},
|
defer metrics.AssertExpectations(t)
|
||||||
},
|
|
||||||
}
|
a := &Agent{
|
||||||
|
plugins: []plugins.Plugin{&plugin},
|
||||||
m1 := cypress.Metric()
|
metrics: &metrics,
|
||||||
m1.Add("name", "foo")
|
Config: &Config{
|
||||||
m1.Add("value", 1.2)
|
Tags: map[string]string{
|
||||||
|
"dc": "us-west-1",
|
||||||
msgs := []*cypress.Message{m1}
|
},
|
||||||
|
},
|
||||||
m2 := cypress.Metric()
|
}
|
||||||
m2.Timestamp = m1.Timestamp
|
|
||||||
m2.Add("name", "foo")
|
m1 := cypress.Metric()
|
||||||
m2.Add("value", 1.2)
|
m1.Add("name", "foo")
|
||||||
m2.AddTag("dc", "us-west-1")
|
m1.Add("value", 1.2)
|
||||||
|
|
||||||
plugin.On("Read").Return(msgs, nil)
|
msgs := []*cypress.Message{m1}
|
||||||
metrics.On("Receive", m2).Return(nil)
|
|
||||||
|
m2 := cypress.Metric()
|
||||||
err := a.crank()
|
m2.Timestamp = m1.Timestamp
|
||||||
require.NoError(t, err)
|
m2.Add("name", "foo")
|
||||||
})
|
m2.Add("value", 1.2)
|
||||||
|
m2.AddTag("dc", "us-west-1")
|
||||||
n.Meow()
|
|
||||||
|
plugin.On("Read").Return(msgs, nil)
|
||||||
|
metrics.On("Receive", m2).Return(nil)
|
||||||
|
|
||||||
|
err := a.crank()
|
||||||
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue