Skip to content

Commit

Permalink
FIX: Incorrect test behaviour when no namespace nor labels are injected
Browse files Browse the repository at this point in the history
  • Loading branch information
angelbarrera92 committed Jun 23, 2023
1 parent e8e1830 commit 3e4383e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/app/prometheus-multi-tenant-proxy/reverse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,13 @@ func TestReverse_ModifyGet(t *testing.T) {
}

func TestReverse_NoNs(t *testing.T) {
// A request without namespaces nor labels
// will end up with a query string containing an empty prometheus query.
tripper := ReversePrometheusRoundTripper{
prometheusServerURL: base,
}
path := "/api/v1/query"
query := "query=foo"
expectedQuery := "query="

// If the context contains an empty namespaces slice, the request isn't touched.
r := getRequest(fmt.Sprintf("%s/api/v1/query?query=foo", promURL), nil, nil)
Expand All @@ -157,8 +159,8 @@ func TestReverse_NoNs(t *testing.T) {
t.Errorf("Path should have been preserved: %v", r.URL.Path)
}
parsed, _ := url.QueryUnescape(r.URL.RawQuery)
if parsed != query {
t.Errorf("Query should have been preserved: %v", r.URL.RawQuery)
if parsed != expectedQuery {
t.Errorf("Query should not have been preserved: %v", r.URL.RawQuery)
}
}

Expand Down

0 comments on commit 3e4383e

Please sign in to comment.