Skip to content

Commit

Permalink
errors.As instead of type casting in unit tests
Browse files Browse the repository at this point in the history
\nSigned-off-by: davis-haba <davishaba@google.com>
  • Loading branch information
davis-haba committed Jan 21, 2023
1 parent c269326 commit 61da4ed
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/mutation/mutators/assignimage/assignimage_mutator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ func TestMutatorForAssignImage(t *testing.T) {
applyTo: []match.ApplyTo{{Groups: []string{""}, Versions: []string{"v1"}, Kinds: []string{"Foo"}}},
},
errFn: func(err error) bool {
_, ok := err.(metadataRootError)
return ok
var tarErr *metadataRootError
return errors.As(err, &tarErr)
},
},
{
Expand All @@ -346,8 +346,8 @@ func TestMutatorForAssignImage(t *testing.T) {
applyTo: []match.ApplyTo{{Groups: []string{""}, Versions: []string{"v1"}, Kinds: []string{"Foo"}}},
},
errFn: func(err error) bool {
_, ok := err.(listTerminalError)
return ok
var tarErr *listTerminalError
return errors.As(err, &tarErr)
},
},
{
Expand All @@ -373,8 +373,8 @@ func TestMutatorForAssignImage(t *testing.T) {
applyTo: []match.ApplyTo{{Groups: []string{""}, Versions: []string{"v1"}, Kinds: []string{"Foo"}}},
},
errFn: func(err error) bool {
_, ok := errors.Unwrap(err).(domainLikePathError)
return ok
var tarErr *domainLikePathError
return errors.As(err, &tarErr)
},
},
}
Expand Down

0 comments on commit 61da4ed

Please sign in to comment.