From c87e727d4620ac2db5d70f252eff0997df3b419c Mon Sep 17 00:00:00 2001 From: Andrew Wormald Date: Fri, 9 Aug 2024 15:55:20 +0100 Subject: [PATCH] write explict record filter tests --- filter_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 filter_test.go diff --git a/filter_test.go b/filter_test.go new file mode 100644 index 0000000..e4c18a4 --- /dev/null +++ b/filter_test.go @@ -0,0 +1,29 @@ +package workflow_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/luno/workflow" +) + +func TestMakeFilter(t *testing.T) { + t.Run("Filter by RunState", func(t *testing.T) { + filter := workflow.MakeFilter(workflow.FilterByRunState(workflow.RunStateInitiated)) + require.True(t, filter.ByRunState().Enabled, "Expected RunState filter to be enabled") + require.Equal(t, "1", filter.ByRunState().Value, "Expected RunState filter value to be 5") + }) + + t.Run("Filter by ForeignID", func(t *testing.T) { + filter := workflow.MakeFilter(workflow.FilterByForeignID("test value")) + require.True(t, filter.ByForeignID().Enabled, "Expected foreign ID filter to be enabled") + require.Equal(t, "test value", filter.ByForeignID().Value, "Expected foreign ID filter value to be 5") + }) + + t.Run("Filter by Status", func(t *testing.T) { + filter := workflow.MakeFilter(workflow.FilterByStatus(9)) + require.True(t, filter.ByStatus().Enabled, "Expected status filter to be enabled") + require.Equal(t, "9", filter.ByStatus().Value, "Expected status filter value to be 5") + }) +}