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) {
|
2021-03-17 06:17:41 -05:00
|
|
|
t.Run("extractProxyPath", func(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
|
|
originalRawPath string
|
|
|
|
exp string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
"/api/datasources/proxy/1",
|
|
|
|
"",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"/api/datasources/proxy/1/some/thing",
|
|
|
|
"some/thing",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"/api/datasources/proxy/54/api/services/afsd%2Fafsd/operations",
|
|
|
|
"api/services/afsd%2Fafsd/operations",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
|
|
t.Run("Given raw path, should extract expected proxy path", func(t *testing.T) {
|
|
|
|
assert.Equal(t, tc.exp, extractProxyPath(tc.originalRawPath))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
2018-10-03 05:55:01 -05:00
|
|
|
}
|