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 defer wrong inner function calls #1937

Merged
merged 3 commits into from
May 15, 2023
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
6 changes: 4 additions & 2 deletions inttestutils/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ func CountArtifactsInPath(pattern string, serverDetails *config.ServerDetails, t
searchCmd.SetServerDetails(serverDetails).SetSpec(spec.NewBuilder().Pattern(pattern).BuildSpec())
reader, err := searchCmd.Search()
assert.NoError(t, err)
defer assert.NoError(t, reader.Close())
defer func() {
assert.NoError(t, reader.Close())
}()
length, err := reader.Length()
assert.NoError(t, err)
return length
Expand All @@ -114,11 +116,11 @@ func WaitForCreationInArtifactory(pattern string, serverDetails *config.ServerDe
for i := 0; i < 20; i++ {
reader, err := searchCmd.Search()
assert.NoError(t, err)
defer assert.NoError(t, reader.Close())
if !reader.IsEmpty() {
return
}
time.Sleep(5 * time.Second)
assert.NoError(t, reader.Close())
}
assert.Fail(t, "Couldn't find in target Artifactory: "+pattern)
}
Expand Down
4 changes: 3 additions & 1 deletion npm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,9 @@ func TestNpmPackInstall(t *testing.T) {
buildInfoService := utils.CreateBuildInfoService()
goBuild, err := buildInfoService.GetOrCreateBuild(tests.NpmBuildName, buildNumber)
assert.NoError(t, err)
defer assert.NoError(t, goBuild.Clean())
defer func() {
assert.NoError(t, goBuild.Clean())
}()
_, err = goBuild.ToBuildInfo()
assert.Error(t, err)
}
Expand Down
Loading