mirror of
https://github.com/grafana/grafana.git
synced 2024-12-30 10:47:30 -06:00
8c765e8068
* API: Rewrite tests from goconvey Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Fix test Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * Fix tests Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
35 lines
790 B
Go
35 lines
790 B
Go
package api
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestDataProxy(t *testing.T) {
|
|
testCases := []struct {
|
|
desc string
|
|
origPath string
|
|
proxyPath string
|
|
exp string
|
|
}{
|
|
{
|
|
"Should append trailing slash to proxy path if original path has a trailing slash",
|
|
"/api/datasources/proxy/6/api/v1/query_range/",
|
|
"api/v1/query_range/",
|
|
"api/v1/query_range/",
|
|
},
|
|
{
|
|
"Should not append trailing slash to proxy path if original path doesn't have a trailing slash",
|
|
"/api/datasources/proxy/6/api/v1/query_range",
|
|
"api/v1/query_range",
|
|
"api/v1/query_range",
|
|
},
|
|
}
|
|
for _, tc := range testCases {
|
|
t.Run(tc.desc, func(t *testing.T) {
|
|
assert.Equal(t, tc.exp, ensureProxyPathTrailingSlash(tc.origPath, tc.proxyPath))
|
|
})
|
|
}
|
|
}
|