30 lines
632 B
Go
30 lines
632 B
Go
|
|
package shim
|
||
|
|
|
||
|
|
import (
|
||
|
|
"os"
|
||
|
|
"testing"
|
||
|
|
|
||
|
|
"github.com/influxdata/telegraf"
|
||
|
|
"github.com/influxdata/telegraf/plugins/inputs"
|
||
|
|
"github.com/stretchr/testify/require"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestLoadConfig(t *testing.T) {
|
||
|
|
os.Setenv("SECRET_TOKEN", "xxxxxxxxxx")
|
||
|
|
os.Setenv("SECRET_VALUE", `test"\test`)
|
||
|
|
|
||
|
|
inputs.Add("test", func() telegraf.Input {
|
||
|
|
return &serviceInput{}
|
||
|
|
})
|
||
|
|
|
||
|
|
c := "./testdata/plugin.conf"
|
||
|
|
conf, err := LoadConfig(&c)
|
||
|
|
require.NoError(t, err)
|
||
|
|
|
||
|
|
inp := conf.Input.(*serviceInput)
|
||
|
|
|
||
|
|
require.Equal(t, "awesome name", inp.ServiceName)
|
||
|
|
require.Equal(t, "xxxxxxxxxx", inp.SecretToken)
|
||
|
|
require.Equal(t, `test"\test`, inp.SecretValue)
|
||
|
|
}
|