opentelemetry-collector icon indicating copy to clipboard operation
opentelemetry-collector copied to clipboard

[mdatagen] bugfix: fix generated package test when skipping goleak, because os package import is forgotten

Open Arthur1 opened this issue 1 year ago • 1 comments

Description

When tests.goleak.skip flag is set to true, the generated_package_test.go file looks like the following image.

スクリーンショット 2024-06-30 062940

Since import os statement is missing, you fail to run the test. I added the missing import in this PR.

Testing

Compare the generated generated_package_test.go when tests.goleak.skip flag is toggle from false to true.

before

--- a/receiver/runnreceiver/generated_package_test.go
+++ b/receiver/runnreceiver/generated_package_test.go
@@ -3,10 +3,10 @@
 package runnreceiver

 import (
-       "go.uber.org/goleak"
        "testing"
 )

 func TestMain(m *testing.M) {
-       goleak.VerifyTestMain(m)
+       // skipping goleak test as per metadata.yml configuration
+       os.Exit(m.Run())
 }

after

--- a/receiver/runnreceiver/generated_package_test.go
+++ b/receiver/runnreceiver/generated_package_test.go
@@ -3,10 +3,11 @@
 package runnreceiver

 import (
-       "go.uber.org/goleak"
+       "os"
        "testing"
 )

 func TestMain(m *testing.M) {
-       goleak.VerifyTestMain(m)
+       // skipping goleak test as per metadata.yml configuration
+       os.Exit(m.Run())
 }

Arthur1 avatar Jun 29 '24 21:06 Arthur1

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 92.33%. Comparing base (ee4eb85) to head (ec245be). Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10486      +/-   ##
==========================================
- Coverage   92.34%   92.33%   -0.02%     
==========================================
  Files         393      393              
  Lines       18620    18620              
==========================================
- Hits        17195    17192       -3     
- Misses       1068     1070       +2     
- Partials      357      358       +1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jul 01 '24 13:07 codecov[bot]