Files
go-zero/core/trace/config_test.go

29 lines
611 B
Go
Raw Normal View History

2023-02-17 13:35:58 +08:00
package trace
import (
"github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/core/logx"
"testing"
)
2023-02-17 13:46:45 +08:00
func TestConfig_parseEndpoint(t *testing.T) {
2023-02-17 13:35:58 +08:00
logx.Disable()
c1 := Config{
2023-02-17 13:37:27 +08:00
Name: "not UDP",
2023-02-17 13:35:58 +08:00
Endpoint: "http://localhost:14268/api/traces",
2023-02-17 13:37:27 +08:00
Batcher: kindJaegerUdp,
2023-02-17 13:35:58 +08:00
}
c2 := Config{
2023-02-17 13:37:27 +08:00
Name: "UDP",
2023-02-17 13:35:58 +08:00
Endpoint: "localhost:6831",
2023-02-17 13:37:27 +08:00
Batcher: kindJaegerUdp,
2023-02-17 13:35:58 +08:00
}
2023-02-17 13:46:45 +08:00
host1, port1 := c1.parseEndpoint()
assert.NotEqual(t, "localhost", host1)
assert.NotEqual(t, "14268", port1)
host2, port2 := c2.parseEndpoint()
assert.Equal(t, "localhost", host2)
assert.Equal(t, "6831", port2)
2023-02-17 13:35:58 +08:00
}