mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
This reverts commit ee6391b691.
This commit is contained in:
46
helper/metricsutil/metricsutil_test.go
Normal file
46
helper/metricsutil/metricsutil_test.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package metricsutil
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/sdk/logical"
|
||||
)
|
||||
|
||||
func TestFormatFromRequest(t *testing.T) {
|
||||
testCases := []struct {
|
||||
original *logical.Request
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
original: &logical.Request{Headers: map[string][]string{
|
||||
"Accept": {
|
||||
"application/vnd.google.protobuf",
|
||||
"schema=\"prometheus/telemetry\"",
|
||||
},
|
||||
}},
|
||||
expected: "prometheus",
|
||||
},
|
||||
{
|
||||
original: &logical.Request{Headers: map[string][]string{
|
||||
"Accept": {
|
||||
"schema=\"prometheus\"",
|
||||
},
|
||||
}},
|
||||
expected: "",
|
||||
},
|
||||
{
|
||||
original: &logical.Request{Headers: map[string][]string{
|
||||
"Accept": {
|
||||
"application/openmetrics-text",
|
||||
},
|
||||
}},
|
||||
expected: "prometheus",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tCase := range testCases {
|
||||
if metricsType := FormatFromRequest(tCase.original); metricsType != tCase.expected {
|
||||
t.Fatalf("expected %s but got %s", tCase.expected, metricsType)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user