mirror of
https://github.com/hanzoai/telemetry.git
synced 2026-10-30 20:01:49 +00:00
Clean up some inconsistencies in the test code across the components. Signed-off-by: Alex Boten <[email protected]>
53 lines
959 B
Go
53 lines
959 B
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package confighttp // import "go.opentelemetry.io/collector/config/confighttp"
|
|
|
|
import (
|
|
"net"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
var _ http.Handler = (*clientInfoHandler)(nil)
|
|
|
|
func TestParseIP(t *testing.T) {
|
|
testCases := []struct {
|
|
name string
|
|
input string
|
|
expected *net.IPAddr
|
|
}{
|
|
{
|
|
name: "addr",
|
|
input: "1.2.3.4",
|
|
expected: &net.IPAddr{
|
|
IP: net.IPv4(1, 2, 3, 4),
|
|
},
|
|
},
|
|
{
|
|
name: "addr:port",
|
|
input: "1.2.3.4:33455",
|
|
expected: &net.IPAddr{
|
|
IP: net.IPv4(1, 2, 3, 4),
|
|
},
|
|
},
|
|
{
|
|
name: "protocol://addr:port",
|
|
input: "http://1.2.3.4:33455",
|
|
expected: nil,
|
|
},
|
|
{
|
|
name: "addr/path",
|
|
input: "1.2.3.4/orders",
|
|
expected: nil,
|
|
},
|
|
}
|
|
for _, tt := range testCases {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
assert.Equal(t, tt.expected, parseIP(tt.input))
|
|
})
|
|
}
|
|
}
|