diff --git a/predicate/predicate.go b/predicate/predicate.go index 6d92c42..bc0bca5 100644 --- a/predicate/predicate.go +++ b/predicate/predicate.go @@ -40,9 +40,9 @@ func ToNestedStep(name string, p *pipeline.Pipeline, predicate Predicate) pipeli return step } -// WrapIn returns a new step that wraps the given step and executes its action only if the given Predicate evaluates true. +// If returns a new step that wraps the given step and executes its action only if the given Predicate evaluates true. // The pipeline.Context from the pipeline is passed through the given action. -func WrapIn(originalStep pipeline.Step, predicate Predicate) pipeline.Step { +func If(predicate Predicate, originalStep pipeline.Step) pipeline.Step { wrappedStep := pipeline.Step{Name: originalStep.Name} wrappedStep.F = func(ctx pipeline.Context) pipeline.Result { if predicate(ctx, wrappedStep) { diff --git a/predicate/predicate_test.go b/predicate/predicate_test.go index 1e2ec54..f078cc4 100644 --- a/predicate/predicate_test.go +++ b/predicate/predicate_test.go @@ -99,7 +99,7 @@ func TestToNestedStep(t *testing.T) { } } -func TestWrapIn(t *testing.T) { +func TestIf(t *testing.T) { counter := 0 tests := map[string]struct { givenPredicate Predicate @@ -122,7 +122,7 @@ func TestWrapIn(t *testing.T) { counter++ return pipeline.Result{} }) - wrapped := WrapIn(step, tt.givenPredicate) + wrapped := If(tt.givenPredicate, step) result := wrapped.F(nil) require.NoError(t, result.Err) assert.Equal(t, tt.expectedCalls, counter)