summaryrefslogtreecommitdiff
path: root/pkg/hooks
diff options
context:
space:
mode:
authorSascha Grunert <sgrunert@redhat.com>2022-07-05 11:42:22 +0200
committerSascha Grunert <sgrunert@redhat.com>2022-07-05 16:06:32 +0200
commit251d91699de4e9aaab53ab6fea262d4b6bdaae8e (patch)
tree1995c85a69f48bf129565ca60ea0b3d6205a04b4 /pkg/hooks
parent340eeed0cb20855f1e6d2670704cfe67df3314f6 (diff)
downloadpodman-251d91699de4e9aaab53ab6fea262d4b6bdaae8e.tar.gz
podman-251d91699de4e9aaab53ab6fea262d4b6bdaae8e.tar.bz2
podman-251d91699de4e9aaab53ab6fea262d4b6bdaae8e.zip
libpod: switch to golang native error wrapping
We now use the golang error wrapping format specifier `%w` instead of the deprecated github.com/pkg/errors package. [NO NEW TESTS NEEDED] Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
Diffstat (limited to 'pkg/hooks')
-rw-r--r--pkg/hooks/exec/runtimeconfigfilter_test.go28
1 files changed, 18 insertions, 10 deletions
diff --git a/pkg/hooks/exec/runtimeconfigfilter_test.go b/pkg/hooks/exec/runtimeconfigfilter_test.go
index 5c13a76e1..a4e9b1fdb 100644
--- a/pkg/hooks/exec/runtimeconfigfilter_test.go
+++ b/pkg/hooks/exec/runtimeconfigfilter_test.go
@@ -3,12 +3,12 @@ package exec
import (
"context"
"encoding/json"
+ "errors"
"os"
"testing"
"time"
spec "github.com/opencontainers/runtime-spec/specs-go"
- "github.com/pkg/errors"
"github.com/stretchr/testify/assert"
)
@@ -18,13 +18,14 @@ func TestRuntimeConfigFilter(t *testing.T) {
rootUint32 := uint32(0)
binUser := int(1)
for _, tt := range []struct {
- name string
- contextTimeout time.Duration
- hooks []spec.Hook
- input *spec.Spec
- expected *spec.Spec
- expectedHookError string
- expectedRunError error
+ name string
+ contextTimeout time.Duration
+ hooks []spec.Hook
+ input *spec.Spec
+ expected *spec.Spec
+ expectedHookError string
+ expectedRunError error
+ expectedRunErrorString string
}{
{
name: "no-op",
@@ -231,7 +232,8 @@ func TestRuntimeConfigFilter(t *testing.T) {
Path: "rootfs",
},
},
- expectedRunError: unexpectedEndOfJSONInput,
+ expectedRunError: unexpectedEndOfJSONInput,
+ expectedRunErrorString: unexpectedEndOfJSONInput.Error(),
},
} {
test := tt
@@ -243,7 +245,13 @@ func TestRuntimeConfigFilter(t *testing.T) {
defer cancel()
}
hookErr, err := RuntimeConfigFilter(ctx, test.hooks, test.input, DefaultPostKillTimeout)
- assert.Equal(t, test.expectedRunError, errors.Cause(err))
+ if test.expectedRunError != nil {
+ if test.expectedRunErrorString != "" {
+ assert.Contains(t, err.Error(), test.expectedRunErrorString)
+ } else {
+ assert.True(t, errors.Is(err, test.expectedRunError))
+ }
+ }
if test.expectedHookError == "" {
if hookErr != nil {
t.Fatal(hookErr)