Skip to content

Commit

Permalink
Fix other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyhb committed Oct 23, 2024
1 parent 23440b7 commit 8558d8a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,11 @@ func (a *aggregator) Remove(ctx context.Context, eval Evaluable) error {
if err == ErrExpressionPartNotFound {
return ErrEvaluableNotFound
}

if err != nil {
_ = a.removeConstantEvaluable(ctx, eval)
return err
}

stats.Merge(s)
}

Expand All @@ -424,6 +425,7 @@ func (a *aggregator) Remove(ctx context.Context, eval Evaluable) error {
if err := a.removeConstantEvaluable(ctx, eval); err != nil {
return err
}
return nil
}

if stats.Slow() == 0 {
Expand Down
8 changes: 4 additions & 4 deletions expr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,15 +717,15 @@ func TestAddRemove(t *testing.T) {
// And remove.
err = e.Remove(ctx, loader.AddEval(tex(`event.data.another < "no"`)))
require.NoError(t, err)
require.Equal(t, 1, e.Len())
require.Equal(t, 1, e.SlowLen())
require.Equal(t, 2, e.SlowLen())
require.Equal(t, 2, e.Len())
require.Equal(t, 0, e.FastLen())

// And yeet out another non-existent expression
err = e.Remove(ctx, loader.AddEval(tex(`event.data.another != "i'm not here" && a != "b"`)))
require.Error(t, ErrEvaluableNotFound, err)
require.Equal(t, 1, e.Len())
require.Equal(t, 1, e.SlowLen())
require.Equal(t, 2, e.Len())
require.Equal(t, 2, e.SlowLen())
require.Equal(t, 0, e.FastLen())
})
}
Expand Down

0 comments on commit 8558d8a

Please sign in to comment.