Path: blob/main/component/loki/source/kubernetes/kubernetes_test.go
4096 views
package kubernetes12import (3"testing"45"github.com/grafana/agent/pkg/river"6"github.com/stretchr/testify/require"7)89func TestRiverConfig(t *testing.T) {10var exampleRiverConfig = `11targets = [12{"__address__" = "localhost:9090", "foo" = "bar"},13{"__address__" = "localhost:8080", "foo" = "buzz"},14]15forward_to = []16client {17api_server = "localhost:9091"18}19`2021var args Arguments22err := river.Unmarshal([]byte(exampleRiverConfig), &args)23require.NoError(t, err)24}2526func TestBadRiverConfig(t *testing.T) {27var exampleRiverConfig = `28targets = [29{"__address__" = "localhost:9090", "foo" = "bar"},30{"__address__" = "localhost:8080", "foo" = "buzz"},31]32forward_to = []33client {34api_server = "localhost:9091"35bearer_token = "token"36bearer_token_file = "/path/to/file.token"37}38`3940// Make sure the squashed HTTPClientConfig Validate function is being utilized correctly41var args Arguments42err := river.Unmarshal([]byte(exampleRiverConfig), &args)43require.ErrorContains(t, err, "at most one of bearer_token & bearer_token_file must be configured")44}454647