Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ShourieG committed Feb 5, 2024
1 parent 9347ff6 commit f7b2d19
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions x-pack/filebeat/input/websocket/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
conf "github.com/elastic/elastic-agent-libs/config"
"github.com/elastic/elastic-agent-libs/logp"
"github.com/elastic/elastic-agent-libs/mapstr"
"github.com/google/go-cmp/cmp"

"github.com/google/go-cmp/cmp"
"github.com/gorilla/websocket"
)

Expand All @@ -37,7 +37,6 @@ var inputTests = []struct {
time func() time.Time
persistCursor map[string]interface{}
want []map[string]interface{}
wantCursor []map[string]interface{}
wantErr error
}{
{
Expand Down Expand Up @@ -302,24 +301,6 @@ func TestInput(t *testing.T) {
t.Errorf("unexpected result for event %d: got:- want:+\n%s", i, cmp.Diff(got.Fields, mapstr.M(test.want[i])))
}
}

switch {
case len(test.wantCursor) == 0 && len(client.cursors) == 0:
return
case len(test.wantCursor) == 0:
t.Errorf("unexpected cursors: %v", client.cursors)
return
}
if len(client.cursors) < len(test.wantCursor) {
t.Errorf("unexpected number of cursors events: got:%d want at least:%d", len(client.cursors), len(test.wantCursor))
test.wantCursor = test.wantCursor[:len(client.published)]
}
client.published = client.published[:len(test.want)]
for i, got := range client.cursors {
if !reflect.DeepEqual(mapstr.M(got), mapstr.M(test.wantCursor[i])) {
t.Errorf("unexpected cursor for event %d: got:- want:+\n%s", i, cmp.Diff(got, test.wantCursor[i]))
}
}
})
}
}
Expand Down

0 comments on commit f7b2d19

Please sign in to comment.