mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Query endpoint refactor (#41637)
Get rid of using legacydata.RequestHandler in HTTPServer, /api/tsdb/query and pkg/expr with the goal of deprecating /api/tsdb/query and remove it completely eventually. This is the first step of cleaning up the HTTP API query endpoint. Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com> Co-authored-by: Alexander Emelin <frvzmb@gmail.com>
This commit is contained in:
committed by
GitHub
parent
6e8cc426d6
commit
8927a3ca20
@@ -6,6 +6,7 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
// StringsFallback2 returns the first of two not empty strings.
|
||||
@@ -108,3 +109,12 @@ func ToCamelCase(str string) string {
|
||||
|
||||
return strings.Join(finalParts, "")
|
||||
}
|
||||
|
||||
func Capitalize(s string) string {
|
||||
if len(s) == 0 {
|
||||
return s
|
||||
}
|
||||
r := []rune(s)
|
||||
r[0] = unicode.ToUpper(r[0])
|
||||
return string(r)
|
||||
}
|
||||
|
||||
@@ -88,8 +88,20 @@ func TestToCamelCase(t *testing.T) {
|
||||
"snake_case_string": "snakeCaseString",
|
||||
"mixed-case_string": "mixedCaseString",
|
||||
"alreadyCamelCase": "alreadyCamelCase",
|
||||
"": "",
|
||||
}
|
||||
for input, expected := range tests {
|
||||
assert.Equal(t, expected, ToCamelCase(input))
|
||||
}
|
||||
}
|
||||
|
||||
func TestCapitalize(t *testing.T) {
|
||||
tests := map[string]string{
|
||||
"properly capitalizes": "Properly capitalizes",
|
||||
"Already capitalized": "Already capitalized",
|
||||
"": "",
|
||||
}
|
||||
for input, expected := range tests {
|
||||
assert.Equal(t, expected, Capitalize(input))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user