Path: blob/main/component/discovery/consul/consul_test.go
4096 views
package consul12import (3"testing"45"github.com/grafana/agent/pkg/river"6"github.com/stretchr/testify/require"7)89func TestRiverConfig(t *testing.T) {10var exampleRiverConfig = `11server = "consul.example.com:8500"12services = ["my-service"]13token = "my-token"14allow_stale = false15node_meta = { foo = "bar" }16`1718var args Arguments19err := river.Unmarshal([]byte(exampleRiverConfig), &args)20require.NoError(t, err)21}2223func TestBadRiverConfig(t *testing.T) {24var exampleRiverConfig = `25server = "consul.example.com:8500"26services = ["my-service"]27bearer_token = "token"28bearer_token_file = "/path/to/file.token"29`3031// Make sure the squashed HTTPClientConfig Validate function is being utilized correctly32var args Arguments33err := river.Unmarshal([]byte(exampleRiverConfig), &args)34require.ErrorContains(t, err, "at most one of bearer_token & bearer_token_file must be configured")35}363738