Skip to content

Commit

Permalink
add test for regex
Browse files Browse the repository at this point in the history
  • Loading branch information
WTFox committed Apr 28, 2022
1 parent fb1071e commit dd453ba
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/scout/scout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,24 @@ func TestScoutWithMapping(t *testing.T) {
})
}

func TestScoutWithRegex(t *testing.T) {
is := is.New(t)

t.Run("instantiation", func(t *testing.T) {
s := New("b.r", jsonMapping(), true)
is.Equal(reflect.TypeOf(s).String(), "scout.Scout")
})

t.Run("finds wildcard value", func(t *testing.T) {
s := New("b.r", jsonMapping(), true)
found, err := s.DoSearch()
is.NoErr(err)

is.Equal(len(found), 1)
is.Equal(found[0], ".foo")
})
}

func jsonArray() []any {
in := []byte(`
[{
Expand Down

0 comments on commit dd453ba

Please sign in to comment.