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

Fix G307 errors in gosec evaluation #704

Merged
merged 1 commit into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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