Do not rely on external server for amon unit tests
This commit is contained in:
parent
16ce06f621
commit
4852b5c11e
|
@ -9,37 +9,8 @@ import (
|
||||||
"github.com/influxdb/telegraf/testutil"
|
"github.com/influxdb/telegraf/testutil"
|
||||||
|
|
||||||
"github.com/influxdb/influxdb/client/v2"
|
"github.com/influxdb/influxdb/client/v2"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
fakeServerKey = "123456"
|
|
||||||
fakeAmonInstance = "https://demo.amon.cx"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestUriOverride(t *testing.T) {
|
|
||||||
a := &Amon{
|
|
||||||
ServerKey: fakeServerKey,
|
|
||||||
AmonInstance: fakeAmonInstance,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := a.Connect()
|
|
||||||
require.NoError(t, err)
|
|
||||||
err = a.Write(testutil.MockBatchPoints().Points())
|
|
||||||
require.NoError(t, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAuthenticatedUrl(t *testing.T) {
|
|
||||||
a := &Amon{
|
|
||||||
ServerKey: fakeServerKey,
|
|
||||||
AmonInstance: fakeAmonInstance,
|
|
||||||
}
|
|
||||||
|
|
||||||
authUrl := a.authenticatedUrl()
|
|
||||||
assert.EqualValues(t, fmt.Sprintf("%s/api/system/%s", fakeAmonInstance, fakeServerKey), authUrl)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestBuildPoint(t *testing.T) {
|
func TestBuildPoint(t *testing.T) {
|
||||||
var tagtests = []struct {
|
var tagtests = []struct {
|
||||||
ptIn *client.Point
|
ptIn *client.Point
|
||||||
|
|
Loading…
Reference in New Issue