-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathurl_test.go
44 lines (40 loc) · 885 Bytes
/
url_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package tracing
import (
"net/url"
"testing"
"github.com/stretchr/testify/require"
)
func TestGetURLParts(t *testing.T) {
tests := []struct {
url string
expected urlParts
}{
{
url: "https://api.smith.langchain.com/otel/v1/traces?x-api-key=aa&LANGSMITH_PROJECT=bb",
expected: urlParts{
endpoint: "api.smith.langchain.com",
urlPath: "/otel/v1/traces",
headers: map[string]string{
"x-api-key": "aa",
"LANGSMITH_PROJECT": "bb",
},
},
},
{
url: "https://api.smith.langchain.com",
expected: urlParts{
endpoint: "api.smith.langchain.com",
urlPath: "",
headers: map[string]string{},
},
},
}
for _, test := range tests {
t.Run(test.url, func(t *testing.T) {
u, err := url.Parse(test.url)
require.NoError(t, err)
parts := getURLParts(u)
require.Equal(t, test.expected, parts)
})
}
}