Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/grafana-agent
Path: blob/main/component/loki/source/kubernetes/kubernetes_test.go
4096 views
1
package kubernetes
2
3
import (
4
"testing"
5
6
"github.com/grafana/agent/pkg/river"
7
"github.com/stretchr/testify/require"
8
)
9
10
func TestRiverConfig(t *testing.T) {
11
var exampleRiverConfig = `
12
targets = [
13
{"__address__" = "localhost:9090", "foo" = "bar"},
14
{"__address__" = "localhost:8080", "foo" = "buzz"},
15
]
16
forward_to = []
17
client {
18
api_server = "localhost:9091"
19
}
20
`
21
22
var args Arguments
23
err := river.Unmarshal([]byte(exampleRiverConfig), &args)
24
require.NoError(t, err)
25
}
26
27
func TestBadRiverConfig(t *testing.T) {
28
var exampleRiverConfig = `
29
targets = [
30
{"__address__" = "localhost:9090", "foo" = "bar"},
31
{"__address__" = "localhost:8080", "foo" = "buzz"},
32
]
33
forward_to = []
34
client {
35
api_server = "localhost:9091"
36
bearer_token = "token"
37
bearer_token_file = "/path/to/file.token"
38
}
39
`
40
41
// Make sure the squashed HTTPClientConfig Validate function is being utilized correctly
42
var args Arguments
43
err := river.Unmarshal([]byte(exampleRiverConfig), &args)
44
require.ErrorContains(t, err, "at most one of bearer_token & bearer_token_file must be configured")
45
}
46
47