-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 report on crashed provider + dedupe shutdown + fix multierr nil
1. Crashed providers print their plugin panic and then an error message about being unable to shutdown the provider. This is wrong and misleading. 2. Since we have potentialy multiple runtimes, the shutdown call can come down multiple paths to the same provider, leading to duplication of errors and reporting. Fix it by giving providers one clear shutdown. 3. Multierr did not handle nil errors correctly and would then end up in panic-land. Fixed. Signed-off-by: Dominik Richter <[email protected]>
- Loading branch information
Showing
4 changed files
with
115 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Mondoo, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
package multierr_test | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"go.mondoo.com/cnquery/utils/multierr" | ||
) | ||
|
||
func TestMultiErr(t *testing.T) { | ||
t.Run("add nil errors", func(t *testing.T) { | ||
var e multierr.Errors | ||
e.Add(nil) | ||
e.Add(nil, nil, nil) | ||
assert.Nil(t, e.Deduplicate()) | ||
}) | ||
|
||
t.Run("add mixed errors", func(t *testing.T) { | ||
var e multierr.Errors | ||
e.Add(errors.New("1"), nil, errors.New("1")) | ||
var b multierr.Errors | ||
b.Add(errors.New("1")) | ||
assert.Equal(t, b.Deduplicate(), e.Deduplicate()) | ||
}) | ||
} |