From b8ec434b5d82150a1719e4658a35ed2c6f145518 Mon Sep 17 00:00:00 2001 From: Leon Mika Date: Fri, 24 Oct 2025 17:26:38 +1100 Subject: [PATCH] Added tests and fixed other unit tests --- internal/common/ui/commandctrl/cmdpacks/modpb_test.go | 11 ++++++----- internal/common/ui/commandctrl/cmdpacks/modrs_test.go | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/internal/common/ui/commandctrl/cmdpacks/modpb_test.go b/internal/common/ui/commandctrl/cmdpacks/modpb_test.go index 91aeb02..37f091e 100644 --- a/internal/common/ui/commandctrl/cmdpacks/modpb_test.go +++ b/internal/common/ui/commandctrl/cmdpacks/modpb_test.go @@ -1,8 +1,9 @@ package cmdpacks_test import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestModPB_Copy(t *testing.T) { @@ -10,8 +11,8 @@ func TestModPB_Copy(t *testing.T) { svc := newService(t) _, err := svc.CommandController.ExecuteAndWait(t.Context(), ` - $items = @resultset.Items - $skItems = $items | map { |i| $i.sk } | lists:uniq + items = @resultset.Items + skItems = $items | map { |i| $i.sk } | lists:uniq pb:copy ($skItems | strs:join "\n") `) assert.NoError(t, err) @@ -23,8 +24,8 @@ func TestModPB_Copy(t *testing.T) { svc := newService(t) _, err := svc.CommandController.ExecuteAndWait(t.Context(), ` - $items = @resultset.Items - $skItems = $items | map { |i| $i.alpha } | filter !nil | lists:uniq + items = @resultset.Items + skItems = $items | map { |i| $i.alpha } | filter !nil | lists:uniq pb:copy ($skItems | strs:join "\n") `) assert.NoError(t, err) diff --git a/internal/common/ui/commandctrl/cmdpacks/modrs_test.go b/internal/common/ui/commandctrl/cmdpacks/modrs_test.go index 91f4290..d4ce9a2 100644 --- a/internal/common/ui/commandctrl/cmdpacks/modrs_test.go +++ b/internal/common/ui/commandctrl/cmdpacks/modrs_test.go @@ -71,7 +71,7 @@ func TestModRS_Union(t *testing.T) { svc := newService(t, withDefaultLimit(2)) rsProxy, err := svc.CommandController.ExecuteAndWait(t.Context(), ` - $mr = rs:union @resultset (rs:next-page @resultset) + mr = rs:union @resultset (rs:next-page @resultset) assert (eq (len $mr.Items) 3) "expected len == 3" assert (eq $mr.Items.(0).pk "abc") "expected 0.pk" @@ -162,14 +162,14 @@ func TestModRS_First(t *testing.T) { { descr: "returns the first item in sorted order", cmd: ` - $rs = rs:query 'pk="abc"' -table service-test-data + rs = rs:query 'pk="abc"' -table service-test-data assert (eq $rs.First.pk "abc") "expected First.pk == abc" assert (eq $rs.First.sk "111") "expected First.sk == 111" `, }, { descr: "returns the first item in single item", cmd: ` - $rs = rs:query 'pk="abc" and sk="222"' -table service-test-data + rs = rs:query 'pk="abc" and sk="222"' -table service-test-data assert (eq $rs.First.pk "abc") "expected First.pk == abc" assert (eq $rs.First.sk "222") "expected First.sk == 222" assert (eq $rs.First.beta 1231) "expected First.beta == 1231" @@ -177,7 +177,7 @@ func TestModRS_First(t *testing.T) { }, { descr: "returns the first item in empty result", cmd: ` - $rs = rs:query 'pk="zzz"' -table service-test-data + rs = rs:query 'pk="zzz"' -table service-test-data assert (eq $rs.First ()) "expected First to be nil" `, },