-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chore] cleanup confighttp tests (#11176)
#### Description Minor life improvements when reviewing the tests, - Using stdlib for error reading - Using the config client from test server - Moving examples into their own file for easy discovery/maintainability #### Link to tracking issue N/A
- Loading branch information
1 parent
37f7833
commit 6fab8ae
Showing
3 changed files
with
50 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package confighttp | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
|
||
"go.opentelemetry.io/collector/component/componenttest" | ||
) | ||
|
||
func ExampleServerConfig() { | ||
settings := NewDefaultServerConfig() | ||
settings.Endpoint = "localhost:443" | ||
|
||
s, err := settings.ToServer( | ||
context.Background(), | ||
componenttest.NewNopHost(), | ||
componenttest.NewNopTelemetrySettings(), | ||
http.HandlerFunc(func(http.ResponseWriter, *http.Request) {})) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
l, err := settings.ToListener(context.Background()) | ||
if err != nil { | ||
panic(err) | ||
} | ||
if err = s.Serve(l); err != nil { | ||
panic(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters