Compare commits

..

No commits in common. "b8ec434b5d82150a1719e4658a35ed2c6f145518" and "4e41ae9cd2dc2d0644775bd3ae523bfb76b02ef6" have entirely different histories.

2 changed files with 8 additions and 48 deletions

View file

@ -1,9 +1,8 @@
package cmdpacks_test
import (
"testing"
"github.com/stretchr/testify/assert"
"testing"
)
func TestModPB_Copy(t *testing.T) {
@ -11,8 +10,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)
@ -24,8 +23,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)

View file

@ -2,11 +2,10 @@ package cmdpacks_test
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"lmika.dev/cmd/dynamo-browse/internal/common/ui/commandctrl/cmdpacks"
"lmika.dev/cmd/dynamo-browse/internal/dynamo-browse/models"
"github.com/stretchr/testify/assert"
"testing"
)
func TestModRS_New(t *testing.T) {
@ -71,7 +70,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"
@ -153,41 +152,3 @@ func TestModRS_Query(t *testing.T) {
})
}
}
func TestModRS_First(t *testing.T) {
tests := []struct {
descr string
cmd string
}{
{
descr: "returns the first item in sorted order",
cmd: `
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
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"
`,
}, {
descr: "returns the first item in empty result",
cmd: `
rs = rs:query 'pk="zzz"' -table service-test-data
assert (eq $rs.First ()) "expected First to be nil"
`,
},
}
for _, tt := range tests {
t.Run(tt.descr, func(t *testing.T) {
svc := newService(t)
_, err := svc.CommandController.ExecuteAndWait(t.Context(), tt.cmd)
assert.NoError(t, err)
})
}
}