Skip to content

Commit

Permalink
[NEW!!!] Only stop proservices if err is nil
Browse files Browse the repository at this point in the history
It'd be safe today to do so, but might not be tomorrow.
The good practice is always to not touch the returned object if err is not nil.
  • Loading branch information
CarlosNihelton committed Apr 19, 2024
1 parent 0cb6f35 commit d3426c8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion windows-agent/internal/proservices/proservices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ func TestNew(t *testing.T) {
}

s, err := proservices.New(ctx, publicDir, privateDir, proservices.WithRegistry(reg))
defer s.Stop(ctx)
if err == nil {
defer s.Stop(ctx)
}
if tc.wantErr {
require.Error(t, err, "New should return an error")
return
Expand Down

0 comments on commit d3426c8

Please sign in to comment.