Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error checking on unit tests #2959

Merged
merged 9 commits into from
Apr 20, 2021

Conversation

mx-psi
Copy link
Member

@mx-psi mx-psi commented Apr 19, 2021

Description:

Fix errcheck errors on test code, counterpart to #2881.

Link to tracking Issue: Updates #2789

To be tracked on #2819

@mx-psi mx-psi marked this pull request as ready for review April 19, 2021 17:35
@mx-psi mx-psi requested a review from a team April 19, 2021 17:35
@codecov
Copy link

codecov bot commented Apr 19, 2021

Codecov Report

Merging #2959 (b034e7f) into main (cdebd4c) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2959   +/-   ##
=======================================
  Coverage   91.62%   91.62%           
=======================================
  Files         312      312           
  Lines       15445    15445           
=======================================
  Hits        14151    14151           
  Misses        884      884           
  Partials      410      410           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cdebd4c...b034e7f. Read the comment docs.

Copy link
Member Author

@mx-psi mx-psi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the changes are adding a require.NoError call with some error, I left a comment for a couple of them in which I am not super sure

receiver/kafkareceiver/kafka_receiver_test.go Show resolved Hide resolved
@@ -802,7 +802,7 @@ func TestShutdown(t *testing.T) {
client := &http.Client{}
resp, err2 := client.Do(req)
if err2 == nil {
ioutil.ReadAll(resp.Body)
ioutil.ReadAll(resp.Body) // nolint:errcheck
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what's the point of this since the output is not used

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the documentation https://golang.org/pkg/net/http/ the Body needs to be closed, but you don't have to read all.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can replace with a resp.Body.Close() call then

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

config/configauth/oidc_server_test.go Outdated Show resolved Hide resolved
exporter/jaegerexporter/exporter_test.go Outdated Show resolved Hide resolved
exporter/jaegerexporter/exporter_test.go Outdated Show resolved Hide resolved
exporter/prometheusexporter/end_to_end_test.go Outdated Show resolved Hide resolved
exporter/prometheusexporter/end_to_end_test.go Outdated Show resolved Hide resolved
@@ -88,7 +88,7 @@ func TestZipkinExporter_roundtripJSON(t *testing.T) {
require.NotNil(t, zi)

require.NoError(t, zi.Start(context.Background(), componenttest.NewNopHost()))
defer zi.Shutdown(context.Background())
defer func() { require.NoError(t, zi.Shutdown(context.Background())) }()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everywhere in the PR :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍, makes sense, I can search and replace.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -802,7 +802,7 @@ func TestShutdown(t *testing.T) {
client := &http.Client{}
resp, err2 := client.Do(req)
if err2 == nil {
ioutil.ReadAll(resp.Body)
ioutil.ReadAll(resp.Body) // nolint:errcheck
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the documentation https://golang.org/pkg/net/http/ the Body needs to be closed, but you don't have to read all.

@bogdandrutu bogdandrutu merged commit 9b382e6 into open-telemetry:main Apr 20, 2021
@mx-psi mx-psi deleted the mx-psi/errcheck-test branch April 20, 2021 17:55
hughesjj pushed a commit to hughesjj/opentelemetry-collector that referenced this pull request Apr 27, 2023
…ry#2959)

- now supports metrics datatype.
- also supports filtering by name and attributes (metrics only)
- query URL has changed from `/` to `/spans` and `/metrics`
- fixed a number of other subtle bugs/issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants