- add pubcli compare command to rank nearby stores by filtered deal coverage, bogo count, aggregate score, and distance tie-breaks - support --count (1-10) for comparison breadth and emit structured JSON/text output with ranked entries - add robust distance token parsing to tolerate upstream distance string formatting differences - add pubcli tui interactive terminal browser with paging, deal detail drill-in, and explicit TTY validation for stdin/stdout - share deal-filter flag registration across root/tui/compare and add --sort support in root execution path - validate sort mode early and allow canonical aliases (end, expiry, expiration) while preserving explicit invalid-arg guidance - expand tolerant CLI normalization for new commands/flags and aliases (orderby, sortby, count, bare-flag rewrite for compare/tui) - update quick-start flag list and integration tests to cover compare help and normalization behavior
65 lines
1.6 KiB
Go
65 lines
1.6 KiB
Go
package cmd
|
|
|
|
import (
|
|
"bytes"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestRunCLI_CompletionZsh(t *testing.T) {
|
|
var stdout bytes.Buffer
|
|
var stderr bytes.Buffer
|
|
|
|
code := runCLI([]string{"completion", "zsh"}, &stdout, &stderr)
|
|
|
|
assert.Equal(t, 0, code)
|
|
assert.Contains(t, stdout.String(), "#compdef pubcli")
|
|
assert.Empty(t, stderr.String())
|
|
}
|
|
|
|
func TestRunCLI_HelpStores(t *testing.T) {
|
|
var stdout bytes.Buffer
|
|
var stderr bytes.Buffer
|
|
|
|
code := runCLI([]string{"help", "stores"}, &stdout, &stderr)
|
|
|
|
assert.Equal(t, 0, code)
|
|
assert.Contains(t, stdout.String(), "pubcli stores [flags]")
|
|
assert.Empty(t, stderr.String())
|
|
}
|
|
|
|
func TestRunCLI_HelpCompare(t *testing.T) {
|
|
var stdout bytes.Buffer
|
|
var stderr bytes.Buffer
|
|
|
|
code := runCLI([]string{"help", "compare"}, &stdout, &stderr)
|
|
|
|
assert.Equal(t, 0, code)
|
|
assert.Contains(t, stdout.String(), "pubcli compare [flags]")
|
|
assert.Empty(t, stderr.String())
|
|
}
|
|
|
|
func TestRunCLI_TolerantRewriteWithoutNetworkCall(t *testing.T) {
|
|
var stdout bytes.Buffer
|
|
var stderr bytes.Buffer
|
|
|
|
code := runCLI([]string{"stores", "-zip", "33101", "--help"}, &stdout, &stderr)
|
|
|
|
assert.Equal(t, 0, code)
|
|
assert.Contains(t, stdout.String(), "pubcli stores [flags]")
|
|
assert.Contains(t, stderr.String(), "interpreted `-zip` as `--zip`")
|
|
}
|
|
|
|
func TestRunCLI_DoubleDashBoundary(t *testing.T) {
|
|
var stdout bytes.Buffer
|
|
var stderr bytes.Buffer
|
|
|
|
code := runCLI([]string{"stores", "--", "zip", "33101", "--help"}, &stdout, &stderr)
|
|
|
|
assert.Equal(t, 0, code)
|
|
assert.Contains(t, stdout.String(), "pubcli stores [flags]")
|
|
assert.False(t, strings.Contains(stderr.String(), "interpreted `zip` as `--zip`"))
|
|
}
|