Fixed docker

This commit is contained in:
Leon Mika 2025-10-24 17:23:38 +11:00
parent 4e41ae9cd2
commit a1bda94e74

View file

@ -2,10 +2,11 @@ package cmdpacks_test
import ( import (
"fmt" "fmt"
"testing"
"github.com/stretchr/testify/assert"
"lmika.dev/cmd/dynamo-browse/internal/common/ui/commandctrl/cmdpacks" "lmika.dev/cmd/dynamo-browse/internal/common/ui/commandctrl/cmdpacks"
"lmika.dev/cmd/dynamo-browse/internal/dynamo-browse/models" "lmika.dev/cmd/dynamo-browse/internal/dynamo-browse/models"
"github.com/stretchr/testify/assert"
"testing"
) )
func TestModRS_New(t *testing.T) { func TestModRS_New(t *testing.T) {
@ -152,3 +153,41 @@ 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)
})
}
}