Skip to content

Commit

Permalink
Use TypeError in tests to ensure the error is wrapped
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerHelmuth committed Jun 9, 2023
1 parent 4b4e7d0 commit 387625c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
14 changes: 7 additions & 7 deletions pkg/ottl/expression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ func Test_StandardStringGetter(t *testing.T) {
func Test_StandardStringGetter_WrappedError(t *testing.T) {
getter := StandardStringGetter[interface{}]{
Getter: func(ctx context.Context, tCtx interface{}) (interface{}, error) {
return nil, fmt.Errorf("not a TypeError: %w", TypeError(""))
return nil, TypeError("")
},
}
_, err := getter.Get(context.Background(), nil)
Expand Down Expand Up @@ -825,7 +825,7 @@ func Test_StandardStringLikeGetter(t *testing.T) {
func Test_StandardStringLikeGetter_WrappedError(t *testing.T) {
getter := StandardStringLikeGetter[interface{}]{
Getter: func(ctx context.Context, tCtx interface{}) (interface{}, error) {
return nil, fmt.Errorf("not a TypeError: %w", TypeError(""))
return nil, TypeError("")
},
}
_, err := getter.Get(context.Background(), nil)
Expand Down Expand Up @@ -901,7 +901,7 @@ func Test_StandardFloatGetter(t *testing.T) {
func Test_StandardFloatGetter_WrappedError(t *testing.T) {
getter := StandardFloatGetter[interface{}]{
Getter: func(ctx context.Context, tCtx interface{}) (interface{}, error) {
return nil, fmt.Errorf("not a TypeError: %w", TypeError(""))
return nil, TypeError("")
},
}
_, err := getter.Get(context.Background(), nil)
Expand Down Expand Up @@ -1077,7 +1077,7 @@ func Test_StandardFloatLikeGetter(t *testing.T) {
func Test_StandardFloatLikeGetter_WrappedError(t *testing.T) {
getter := StandardFloatLikeGetter[interface{}]{
Getter: func(ctx context.Context, tCtx interface{}) (interface{}, error) {
return nil, fmt.Errorf("not a TypeError: %w", TypeError(""))
return nil, TypeError("")
},
}
_, err := getter.Get(context.Background(), nil)
Expand Down Expand Up @@ -1153,7 +1153,7 @@ func Test_StandardIntGetter(t *testing.T) {
func Test_StandardIntGetter_WrappedError(t *testing.T) {
getter := StandardIntGetter[interface{}]{
Getter: func(ctx context.Context, tCtx interface{}) (interface{}, error) {
return nil, fmt.Errorf("not a TypeError: %w", TypeError(""))
return nil, TypeError("")
},
}
_, err := getter.Get(context.Background(), nil)
Expand Down Expand Up @@ -1329,7 +1329,7 @@ func Test_StandardIntLikeGetter(t *testing.T) {
func Test_StandardIntLikeGetter_WrappedError(t *testing.T) {
getter := StandardIntLikeGetter[interface{}]{
Getter: func(ctx context.Context, tCtx interface{}) (interface{}, error) {
return nil, fmt.Errorf("not a TypeError: %w", TypeError(""))
return nil, TypeError("")
},
}
_, err := getter.Get(context.Background(), nil)
Expand Down Expand Up @@ -1415,7 +1415,7 @@ func Test_StandardPMapGetter(t *testing.T) {
func Test_StandardPMapGetter_WrappedError(t *testing.T) {
getter := StandardPMapGetter[interface{}]{
Getter: func(ctx context.Context, tCtx interface{}) (interface{}, error) {
return nil, fmt.Errorf("not a TypeError: %w", TypeError(""))
return nil, TypeError("")
},
}
_, err := getter.Get(context.Background(), nil)
Expand Down
3 changes: 1 addition & 2 deletions pkg/ottl/ottlfuncs/func_is_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package ottlfuncs

import (
"context"
"fmt"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -63,7 +62,7 @@ func Test_IsMap(t *testing.T) {
func Test_IsMap_Error(t *testing.T) {
exprFunc := isMap[any](&ottl.StandardPMapGetter[any]{
Getter: func(context.Context, interface{}) (interface{}, error) {
return nil, fmt.Errorf("not a TypeError: %w", ottl.TypeError(""))
return nil, ottl.TypeError("")
},
})
_, err := exprFunc(context.Background(), nil)
Expand Down
3 changes: 1 addition & 2 deletions pkg/ottl/ottlfuncs/func_is_string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package ottlfuncs

import (
"context"
"fmt"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -63,7 +62,7 @@ func Test_IsString(t *testing.T) {
func Test_IsString_Error(t *testing.T) {
exprFunc := isString[any](&ottl.StandardStringGetter[any]{
Getter: func(context.Context, interface{}) (interface{}, error) {
return nil, fmt.Errorf("not a TypeError: %w", ottl.TypeError(""))
return nil, ottl.TypeError("")
},
})
_, err := exprFunc(context.Background(), nil)
Expand Down

0 comments on commit 387625c

Please sign in to comment.