1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-08-10 22:31:50 +02:00

Add a unit test to verify the functionality of WithClient for zipkin exporter (#6576)

fix #6533

Co-authored-by: Damien Mathieu <42@dmathieu.com>
This commit is contained in:
Robert Wu
2025-04-03 05:43:57 -04:00
committed by GitHub
parent b4336954b6
commit f60c3a624a

View File

@@ -425,3 +425,38 @@ func TestWithHeaders(t *testing.T) {
assert.Equal(t, headers["name1"], req.Header.Get("name1"))
assert.Equal(t, headers["name2"], req.Header.Get("name2"))
}
func TestWithClient(t *testing.T) {
customClient := &http.Client{
Timeout: 1000,
}
testcases := []struct {
name string
client *http.Client
want *http.Client
description string
}{
{
name: "nil client",
client: nil,
want: http.DefaultClient,
description: "should fall back to default client when nil is provided",
},
{
name: "custom client",
client: customClient,
want: customClient,
description: "should use provided custom client",
},
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
exp, err := New("", WithClient(tc.client))
require.NoError(t, err)
assert.Equal(t, tc.want, exp.client)
})
}
}