2018-10-03 05:55:01 -05:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-11-17 04:31:35 -06:00
|
|
|
"github.com/stretchr/testify/assert"
|
2018-10-03 05:55:01 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestDataProxy(t *testing.T) {
|
2020-11-17 04:31:35 -06:00
|
|
|
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))
|
2018-10-03 05:55:01 -05:00
|
|
|
})
|
2020-11-17 04:31:35 -06:00
|
|
|
}
|
2018-10-03 05:55:01 -05:00
|
|
|
}
|