From d3b4bef531c846dc80d13b8a571eb1a45f4b9193 Mon Sep 17 00:00:00 2001 From: lew Date: Wed, 11 Feb 2026 16:07:19 +0000 Subject: [PATCH] feat: adds some test cases where they were missing, and some minor readme additions --- README.md | 17 +++++++++++++++- testdata/cp__cross-store__ok.ct | 7 +++++++ testdata/cp__err__missing.ct | 3 +++ testdata/cp__ok.ct | 7 +++++++ testdata/export__ok.ct | 6 ++++++ testdata/list-stores__ok.ct | 9 +++++++++ testdata/list__all-suppressed__err.ct | 5 +++++ testdata/list__format__csv__ok.ct | 7 +++++++ testdata/list__format__markdown__ok.ct | 8 ++++++++ testdata/list__format__ndjson__ok.ct | 6 ++++++ testdata/list__no-header__ok.ct | 4 ++++ testdata/list__no-keys__ok.ct | 5 +++++ testdata/list__no-ttl__ok.ct | 5 +++++ testdata/list__no-values__ok.ct | 5 +++++ testdata/multistore__ok.ct | 10 ++++++++++ testdata/mv__cross-store__ok.ct | 7 +++++++ testdata/mv__err__missing.ct | 3 +++ testdata/mv__ok.ct | 7 +++++++ testdata/restore__merge__ok.ct | 9 +++++++++ testdata/restore__stdin__ok.ct | 9 +++++++++ testdata/template__enum__err.ct | 5 +++++ testdata/template__no-template__ok.ct | 5 +++++ testdata/template__ok.ct | 27 ++++++++++++++++++++++++++ testdata/template__require__err.ct | 5 +++++ 24 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 testdata/cp__cross-store__ok.ct create mode 100644 testdata/cp__err__missing.ct create mode 100644 testdata/cp__ok.ct create mode 100644 testdata/export__ok.ct create mode 100644 testdata/list-stores__ok.ct create mode 100644 testdata/list__all-suppressed__err.ct create mode 100644 testdata/list__format__csv__ok.ct create mode 100644 testdata/list__format__markdown__ok.ct create mode 100644 testdata/list__format__ndjson__ok.ct create mode 100644 testdata/list__no-header__ok.ct create mode 100644 testdata/list__no-keys__ok.ct create mode 100644 testdata/list__no-ttl__ok.ct create mode 100644 testdata/list__no-values__ok.ct create mode 100644 testdata/multistore__ok.ct create mode 100644 testdata/mv__cross-store__ok.ct create mode 100644 testdata/mv__err__missing.ct create mode 100644 testdata/mv__ok.ct create mode 100644 testdata/restore__merge__ok.ct create mode 100644 testdata/restore__stdin__ok.ct create mode 100644 testdata/template__enum__err.ct create mode 100644 testdata/template__no-template__ok.ct create mode 100644 testdata/template__ok.ct create mode 100644 testdata/template__require__err.ct diff --git a/README.md b/README.md index b854b7d..484efa1 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,21 @@ Additional Commands:

+Most commands have short aliases for quick access: + +| Command | Alias(es) | +|---------|-----------| +| `set` | `s` | +| `get` | `g` | +| `list` | `ls` | +| `remove` | `rm` | +| `move` | `mv` | +| `copy` | `cp` | +| `list-stores` | `ls-stores`, `lss` | +| `remove-store` | `rm-store`, `rms` | + +

+ ### Installation ```bash @@ -544,7 +559,7 @@ Locked (encrypted without an available identity) and non-UTF-8 (binary) entries # Expire after 1 hour pda set session "123" --ttl 1h -# After 52 minutes and 10 seconds +# After 54 minutes and 10 seconds pda set session2 "xyz" --ttl 54m10s ``` diff --git a/testdata/cp__cross-store__ok.ct b/testdata/cp__cross-store__ok.ct new file mode 100644 index 0000000..8e1c4ce --- /dev/null +++ b/testdata/cp__cross-store__ok.ct @@ -0,0 +1,7 @@ +# Cross-store copy +$ pda set key@src value +$ pda cp key@src key@dst +$ pda get key@src +value +$ pda get key@dst +value diff --git a/testdata/cp__err__missing.ct b/testdata/cp__err__missing.ct new file mode 100644 index 0000000..d152d13 --- /dev/null +++ b/testdata/cp__err__missing.ct @@ -0,0 +1,3 @@ +# Copy non-existent key +$ pda cp nonexistent dest --> FAIL +FAIL cannot move 'nonexistent': no such key diff --git a/testdata/cp__ok.ct b/testdata/cp__ok.ct new file mode 100644 index 0000000..8abbe7b --- /dev/null +++ b/testdata/cp__ok.ct @@ -0,0 +1,7 @@ +# Basic copy +$ pda set source@cpok value +$ pda cp source@cpok dest@cpok +$ pda get source@cpok +value +$ pda get dest@cpok +value diff --git a/testdata/export__ok.ct b/testdata/export__ok.ct new file mode 100644 index 0000000..64d6f21 --- /dev/null +++ b/testdata/export__ok.ct @@ -0,0 +1,6 @@ +# Unfiltered export outputs all entries as NDJSON +$ pda set a@exp 1 +$ pda set b@exp 2 +$ pda export exp +{"key":"a","value":"1","encoding":"text"} +{"key":"b","value":"2","encoding":"text"} diff --git a/testdata/list-stores__ok.ct b/testdata/list-stores__ok.ct new file mode 100644 index 0000000..7269065 --- /dev/null +++ b/testdata/list-stores__ok.ct @@ -0,0 +1,9 @@ +# Functional list-stores: verify created stores appear +$ pda set a@lsalpha 1 +$ pda set b@lsbeta 2 +$ pda ls lsalpha --format tsv +Key Value TTL +a 1 no expiry +$ pda ls lsbeta --format tsv +Key Value TTL +b 2 no expiry diff --git a/testdata/list__all-suppressed__err.ct b/testdata/list__all-suppressed__err.ct new file mode 100644 index 0000000..f96a22b --- /dev/null +++ b/testdata/list__all-suppressed__err.ct @@ -0,0 +1,5 @@ +# Error when all columns are suppressed +$ pda set a@las 1 +$ pda ls las --no-keys --no-values --no-ttl --> FAIL +FAIL cannot ls '@las': no columns selected +hint disable --no-keys, --no-values, or --no-ttl diff --git a/testdata/list__format__csv__ok.ct b/testdata/list__format__csv__ok.ct new file mode 100644 index 0000000..9869a27 --- /dev/null +++ b/testdata/list__format__csv__ok.ct @@ -0,0 +1,7 @@ +# CSV format output +$ pda set a@csv 1 +$ pda set b@csv 2 +$ pda ls csv --format csv +Key,Value,TTL +a,1,no expiry +b,2,no expiry diff --git a/testdata/list__format__markdown__ok.ct b/testdata/list__format__markdown__ok.ct new file mode 100644 index 0000000..c97165e --- /dev/null +++ b/testdata/list__format__markdown__ok.ct @@ -0,0 +1,8 @@ +# Markdown format output +$ pda set a@md 1 +$ pda set b@md 2 +$ pda ls md --format markdown +| Key | Value | TTL | +| --- | --- | --- | +| a | 1 | no expiry | +| b | 2 | no expiry | diff --git a/testdata/list__format__ndjson__ok.ct b/testdata/list__format__ndjson__ok.ct new file mode 100644 index 0000000..6740b01 --- /dev/null +++ b/testdata/list__format__ndjson__ok.ct @@ -0,0 +1,6 @@ +# NDJSON format output via list +$ pda set a@nj 1 +$ pda set b@nj 2 +$ pda ls nj --format ndjson +{"key":"a","value":"1","encoding":"text"} +{"key":"b","value":"2","encoding":"text"} diff --git a/testdata/list__no-header__ok.ct b/testdata/list__no-header__ok.ct new file mode 100644 index 0000000..63992dc --- /dev/null +++ b/testdata/list__no-header__ok.ct @@ -0,0 +1,4 @@ +# --no-header suppresses the header row +$ pda set a@nh 1 +$ pda ls nh --format tsv --no-header +a 1 no expiry diff --git a/testdata/list__no-keys__ok.ct b/testdata/list__no-keys__ok.ct new file mode 100644 index 0000000..c364e54 --- /dev/null +++ b/testdata/list__no-keys__ok.ct @@ -0,0 +1,5 @@ +# --no-keys suppresses the key column +$ pda set a@nk 1 +$ pda ls nk --format tsv --no-keys +Value TTL +1 no expiry diff --git a/testdata/list__no-ttl__ok.ct b/testdata/list__no-ttl__ok.ct new file mode 100644 index 0000000..c9799cb --- /dev/null +++ b/testdata/list__no-ttl__ok.ct @@ -0,0 +1,5 @@ +# --no-ttl suppresses the TTL column +$ pda set a@nt 1 +$ pda ls nt --format tsv --no-ttl +Key Value +a 1 diff --git a/testdata/list__no-values__ok.ct b/testdata/list__no-values__ok.ct new file mode 100644 index 0000000..9ebb69a --- /dev/null +++ b/testdata/list__no-values__ok.ct @@ -0,0 +1,5 @@ +# --no-values suppresses the value column +$ pda set a@nv 1 +$ pda ls nv --format tsv --no-values +Key TTL +a no expiry diff --git a/testdata/multistore__ok.ct b/testdata/multistore__ok.ct new file mode 100644 index 0000000..ac0ba32 --- /dev/null +++ b/testdata/multistore__ok.ct @@ -0,0 +1,10 @@ +# Operations across multiple stores +$ pda set foo@ms1 bar +$ pda set x@ms2 y +$ pda get foo@ms1 +bar +$ pda get x@ms2 +y +$ pda ls ms2 --format tsv +Key Value TTL +x y no expiry diff --git a/testdata/mv__cross-store__ok.ct b/testdata/mv__cross-store__ok.ct new file mode 100644 index 0000000..4420a35 --- /dev/null +++ b/testdata/mv__cross-store__ok.ct @@ -0,0 +1,7 @@ +# Cross-store move +$ pda set key@src value +$ pda mv key@src key@dst +$ pda get key@dst +value +$ pda get key@src --> FAIL +FAIL cannot get 'key@src': no such key diff --git a/testdata/mv__err__missing.ct b/testdata/mv__err__missing.ct new file mode 100644 index 0000000..6df2ff0 --- /dev/null +++ b/testdata/mv__err__missing.ct @@ -0,0 +1,3 @@ +# Move non-existent key +$ pda mv nonexistent dest --> FAIL +FAIL cannot move 'nonexistent': no such key diff --git a/testdata/mv__ok.ct b/testdata/mv__ok.ct new file mode 100644 index 0000000..0ef7801 --- /dev/null +++ b/testdata/mv__ok.ct @@ -0,0 +1,7 @@ +# Basic move +$ pda set source@mvok value +$ pda mv source@mvok dest@mvok +$ pda get dest@mvok +value +$ pda get source@mvok --> FAIL +FAIL cannot get 'source@mvok': no such key diff --git a/testdata/restore__merge__ok.ct b/testdata/restore__merge__ok.ct new file mode 100644 index 0000000..a8ac11a --- /dev/null +++ b/testdata/restore__merge__ok.ct @@ -0,0 +1,9 @@ +# Merge import updates existing entries and adds new ones +$ pda set existing@mrg old-value +$ fecho dumpfile {"key":"existing","value":"updated","encoding":"text"} {"key":"new","value":"hello","encoding":"text"} +$ pda restore mrg --file dumpfile + ok restored 2 entries into @mrg +$ pda get existing@mrg +updated +$ pda get new@mrg +hello diff --git a/testdata/restore__stdin__ok.ct b/testdata/restore__stdin__ok.ct new file mode 100644 index 0000000..ec2552a --- /dev/null +++ b/testdata/restore__stdin__ok.ct @@ -0,0 +1,9 @@ +# Import from stdin preserves existing entries +$ pda set existing@stn keep-me +$ fecho dumpfile {"key":"new","value":"hello","encoding":"text"} +$ pda restore stn < dumpfile + ok restored 1 entries into @stn +$ pda get existing@stn +keep-me +$ pda get new@stn +hello diff --git a/testdata/template__enum__err.ct b/testdata/template__enum__err.ct new file mode 100644 index 0000000..e2b9f1f --- /dev/null +++ b/testdata/template__enum__err.ct @@ -0,0 +1,5 @@ +# enum errors on invalid value +$ fecho tpl {{ enum .LEVEL "info" "warn" }} +$ pda set level@tple < tpl +$ pda get level@tple LEVEL=debug --> FAIL +FAIL cannot get 'level@tple': template: cmd:1:3: executing "cmd" at : error calling enum: invalid value 'debug', allowed: [info warn] diff --git a/testdata/template__no-template__ok.ct b/testdata/template__no-template__ok.ct new file mode 100644 index 0000000..3615ef1 --- /dev/null +++ b/testdata/template__no-template__ok.ct @@ -0,0 +1,5 @@ +# --no-template outputs raw template syntax without evaluation +$ fecho tpl Hello, {{ .NAME }} +$ pda set tmpl@tplnt < tpl +$ pda get tmpl@tplnt --no-template +Hello, {{ .NAME }} diff --git a/testdata/template__ok.ct b/testdata/template__ok.ct new file mode 100644 index 0000000..324a9fb --- /dev/null +++ b/testdata/template__ok.ct @@ -0,0 +1,27 @@ +# Basic template substitution +$ fecho tpl1 Hello, {{ .NAME }} +$ pda set greeting@tpl < tpl1 +$ pda get greeting@tpl NAME=Alice +Hello, Alice +# Default function provides fallback value +$ fecho tpl2 Hello, {{ default "World" .NAME }} +$ pda set defval@tpl < tpl2 +$ pda get defval@tpl +Hello, World +$ pda get defval@tpl NAME=Bob +Hello, Bob +# Enum function restricts to allowed values +$ fecho tpl3 {{ enum .LEVEL "info" "warn" }} +$ pda set level@tpl < tpl3 +$ pda get level@tpl LEVEL=info +info +# Int function parses integer +$ fecho tpl4 {{ int .N }} +$ pda set number@tpl < tpl4 +$ pda get number@tpl N=42 +42 +# List function parses CSV +$ fecho tpl5 {{ range list .NAMES }}{{.}},{{ end }} +$ pda set names@tpl < tpl5 +$ pda get names@tpl NAMES=Bob,Alice +Bob,Alice, diff --git a/testdata/template__require__err.ct b/testdata/template__require__err.ct new file mode 100644 index 0000000..88c726c --- /dev/null +++ b/testdata/template__require__err.ct @@ -0,0 +1,5 @@ +# require errors when variable is missing +$ fecho tpl {{ require .FILE }} +$ pda set tmpl@tplr < tpl +$ pda get tmpl@tplr --> FAIL +FAIL cannot get 'tmpl@tplr': template: cmd:1:3: executing "cmd" at : error calling require: required value is missing or empty