@@ -12,36 +12,61 @@ import (
12
12
func TestParseDSN (t * testing.T ) {
13
13
type Test struct {
14
14
dsn string
15
- otlp string
15
+ grpc string
16
+ http string
16
17
siteURL string
17
18
}
18
19
19
20
tests := []Test {
20
- {"https://token@uptrace.dev/1" , "otlp.uptrace.dev:4317" , "https://app.uptrace.dev" },
21
- {"https://token@api.uptrace.dev/1" , "otlp.uptrace.dev:4317" , "https://app.uptrace.dev" },
21
+ {
22
+ "https://token@uptrace.dev/1" ,
23
+ "otlp.uptrace.dev:4317" ,
24
+ "otlp.uptrace.dev:443" ,
25
+ "https://app.uptrace.dev" ,
26
+ },
27
+ {
28
+ "https://token@api.uptrace.dev/1" ,
29
+ "otlp.uptrace.dev:4317" ,
30
+ "otlp.uptrace.dev:443" ,
31
+ "https://app.uptrace.dev" ,
32
+ },
22
33
{
23
34
"https://token@demo.uptrace.dev/1?grpc=4317" ,
24
35
"demo.uptrace.dev:4317" ,
25
- "https://demo.uptrace.dev" ,
36
+ "demo.uptrace.dev:443" ,
37
+ "https://demo.uptrace.dev:443" ,
38
+ },
39
+ {
40
+ "https://token@localhost:1234/1" ,
41
+ "localhost:1234" ,
42
+ "localhost:1234" ,
43
+ "https://localhost:1234" ,
44
+ },
45
+ {
46
+ "http://token@localhost:14317/project_id" ,
47
+ "localhost:14317" ,
48
+ "localhost:14318" ,
49
+ "http://localhost:14318" ,
26
50
},
27
- {"https://token@localhost:1234/1" , "localhost:1234" , "https://localhost:1234" },
28
- {"http://token@localhost:14317/project_id" , "localhost:14317" , "http://localhost:14318" },
29
51
{
30
52
"https://AQDan_E_EPe3QAF9fMP0PiVr5UWOu4q5@demo-api.uptrace.dev:4317/1" ,
31
53
"demo-api.uptrace.dev:4317" ,
54
+ "demo-api.uptrace.dev:4317" ,
32
55
"https://demo-api.uptrace.dev:4317" ,
33
56
},
34
57
{
35
58
"http://Qcn7rcwWO_w0ePo7WmeUtw@localhost:14318?grpc=14317" ,
36
59
"localhost:14317" ,
60
+ "localhost:14318" ,
37
61
"http://localhost:14318" ,
38
62
},
39
63
}
40
64
for i , test := range tests {
41
65
t .Run (fmt .Sprint (i ), func (t * testing.T ) {
42
66
dsn , err := uptrace .ParseDSN (test .dsn )
43
67
require .NoError (t , err )
44
- require .Equal (t , test .otlp , dsn .OTLPEndpoint ())
68
+ require .Equal (t , test .grpc , dsn .OTLPGrpcEndpoint ())
69
+ require .Equal (t , test .http , dsn .OTLPHttpEndpoint ())
45
70
require .Equal (t , test .siteURL , dsn .SiteURL ())
46
71
})
47
72
}
0 commit comments