feat: adds some test cases where they were missing, and some minor readme additions

This commit is contained in:
Lewis Wynne 2026-02-11 16:07:19 +00:00
parent bb57b23224
commit d3b4bef531
24 changed files with 180 additions and 1 deletions

View file

@ -104,6 +104,21 @@ Additional Commands:
<p align="center"></p><!-- spacer --> <p align="center"></p><!-- spacer -->
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` |
<p align="center"></p><!-- spacer -->
### Installation ### Installation
```bash ```bash
@ -544,7 +559,7 @@ Locked (encrypted without an available identity) and non-UTF-8 (binary) entries
# Expire after 1 hour # Expire after 1 hour
pda set session "123" --ttl 1h pda set session "123" --ttl 1h
# After 52 minutes and 10 seconds # After 54 minutes and 10 seconds
pda set session2 "xyz" --ttl 54m10s pda set session2 "xyz" --ttl 54m10s
``` ```

7
testdata/cp__cross-store__ok.ct vendored Normal file
View file

@ -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

3
testdata/cp__err__missing.ct vendored Normal file
View file

@ -0,0 +1,3 @@
# Copy non-existent key
$ pda cp nonexistent dest --> FAIL
FAIL cannot move 'nonexistent': no such key

7
testdata/cp__ok.ct vendored Normal file
View file

@ -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

6
testdata/export__ok.ct vendored Normal file
View file

@ -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"}

9
testdata/list-stores__ok.ct vendored Normal file
View file

@ -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

5
testdata/list__all-suppressed__err.ct vendored Normal file
View file

@ -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

7
testdata/list__format__csv__ok.ct vendored Normal file
View file

@ -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

View file

@ -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 |

6
testdata/list__format__ndjson__ok.ct vendored Normal file
View file

@ -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"}

4
testdata/list__no-header__ok.ct vendored Normal file
View file

@ -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

5
testdata/list__no-keys__ok.ct vendored Normal file
View file

@ -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

5
testdata/list__no-ttl__ok.ct vendored Normal file
View file

@ -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

5
testdata/list__no-values__ok.ct vendored Normal file
View file

@ -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

10
testdata/multistore__ok.ct vendored Normal file
View file

@ -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

7
testdata/mv__cross-store__ok.ct vendored Normal file
View file

@ -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

3
testdata/mv__err__missing.ct vendored Normal file
View file

@ -0,0 +1,3 @@
# Move non-existent key
$ pda mv nonexistent dest --> FAIL
FAIL cannot move 'nonexistent': no such key

7
testdata/mv__ok.ct vendored Normal file
View file

@ -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

9
testdata/restore__merge__ok.ct vendored Normal file
View file

@ -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

9
testdata/restore__stdin__ok.ct vendored Normal file
View file

@ -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

5
testdata/template__enum__err.ct vendored Normal file
View file

@ -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 <enum .LEVEL "info" "warn">: error calling enum: invalid value 'debug', allowed: [info warn]

5
testdata/template__no-template__ok.ct vendored Normal file
View file

@ -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 }}

27
testdata/template__ok.ct vendored Normal file
View file

@ -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,

5
testdata/template__require__err.ct vendored Normal file
View file

@ -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 <require .FILE>: error calling require: required value is missing or empty