Skip to content

Commit

Permalink
Fix G07 errors in gosec evaluation
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu committed Mar 26, 2020
1 parent 277f1bf commit 30e98ad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions testbed/tests/scenarios.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
// createConfigFile creates a collector config file that corresponds to the
// sender and receiver used in the test and returns the config file name.
func createConfigFile(
t *testing.T,
sender testbed.DataSender, // Sender to send test data.
receiver testbed.DataReceiver, // Receiver to receive test data.
resultDir string, // Directory to write config file to.
Expand Down Expand Up @@ -128,14 +129,20 @@ service:
// Write the config string to a temporary file.
file, err := ioutil.TempFile("", "agent*.yaml")
if err != nil {
fmt.Print(err)
t.Error(err)
return ""
}
defer file.Close()

defer func() {
err := file.Close()
if err != nil {
t.Error(err)
}
}()

_, err = file.WriteString(config)
if err != nil {
fmt.Print(err)
t.Error(err)
return ""
}

Expand All @@ -156,7 +163,7 @@ func Scenario10kItemsPerSecond(
t.Fatal(err)
}

configFile := createConfigFile(sender, receiver, resultDir, nil)
configFile := createConfigFile(t, sender, receiver, resultDir, nil)
defer os.Remove(configFile)

if configFile == "" {
Expand Down
2 changes: 1 addition & 1 deletion testbed/tests/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func TestTraceAttributesProcessor(t *testing.T) {
`,
}

configFile := createConfigFile(test.sender, test.receiver, resultDir, processors)
configFile := createConfigFile(t, test.sender, test.receiver, resultDir, processors)
defer os.Remove(configFile)

if configFile == "" {
Expand Down

0 comments on commit 30e98ad

Please sign in to comment.