Skip to content

Commit

Permalink
Add tests for paths with query parameters and fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
akrantz01 committed Oct 18, 2021
1 parent 9067e43 commit d9bb5b4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions plugins/inputs/prometheus/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,22 @@ func TestScrapeURLAnnotationsCustomPathWithSep(t *testing.T) {
assert.Equal(t, "http://127.0.0.1:9102/mymetrics", url.String())
}

func TestScrapeURLAnnotationsCustomPathWithQueryParameters(t *testing.T) {
p := pod()
p.Annotations = map[string]string{"prometheus.io/scrape": "true", "prometheus.io/path": "/v1/agent/metrics?format=prometheus"}
url, err := getScrapeURL(p)
assert.NoError(t, err)
assert.Equal(t, "http://127.0.0.1:9102/v1/agent/metrics?format=prometheus", url.String())
}

func TestScrapeURLAnnotationsCustomPathWithFragment(t *testing.T) {
p := pod()
p.Annotations = map[string]string{"prometheus.io/scrape": "true", "prometheus.io/path": "/v1/agent/metrics#prometheus"}
url, err := getScrapeURL(p)
assert.NoError(t, err)
assert.Equal(t, "http://127.0.0.1:9102/v1/agent/metrics#prometheus", url.String())
}

func TestAddPod(t *testing.T) {
prom := &Prometheus{Log: testutil.Logger{}}

Expand Down

0 comments on commit d9bb5b4

Please sign in to comment.