-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: index not found should not trigger error (#218)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
- Loading branch information
1 parent
c04375f
commit cc54ee5
Showing
3 changed files
with
54 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package assert | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/jmespath-community/go-jmespath/pkg/binding" | ||
tassert "github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_project(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
key interface{} | ||
value interface{} | ||
bindings binding.Bindings | ||
want *projection | ||
wantErr bool | ||
}{{ | ||
name: "map index not found", | ||
key: "foo", | ||
value: map[string]interface{}{ | ||
"bar": 42, | ||
}, | ||
bindings: nil, | ||
want: nil, | ||
wantErr: false, | ||
}} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := project(context.TODO(), tt.key, tt.value, tt.bindings) | ||
if tt.wantErr { | ||
tassert.Error(t, err) | ||
tassert.Equal(t, tt.want, got) | ||
} else { | ||
tassert.NoError(t, err) | ||
} | ||
}) | ||
} | ||
} |