test(db format): tests for db format error
This commit is contained in:
parent
e806bd9046
commit
533c1a6cec
6 changed files with 10 additions and 4 deletions
|
|
@ -261,7 +261,7 @@ func ensureSubpath(base, target string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateDBName(name string) error {
|
func validateDBName(name string) error {
|
||||||
if strings.ContainsAny(name, `/\`) {
|
if strings.ContainsAny(name, `/\~`) {
|
||||||
return fmt.Errorf("bad db format, use DB or @DB")
|
return fmt.Errorf("bad db format, use DB or @DB")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
2
testdata/del-db__err__with__invalid_db.ct
vendored
Normal file
2
testdata/del-db__err__with__invalid_db.ct
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
$ pda del-db foo/bar --> FAIL
|
||||||
|
Error: cannot delete-db 'foo/bar': cannot parse db: bad db format, use DB or @DB
|
||||||
2
testdata/get__err__with__invalid_db.ct
vendored
Normal file
2
testdata/get__err__with__invalid_db.ct
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
$ pda get key@foo/bar --> FAIL
|
||||||
|
Error: cannot get 'key@foo/bar': bad db format, use DB or @DB
|
||||||
4
testdata/help__ok.ct
vendored
4
testdata/help__ok.ct
vendored
|
|
@ -25,7 +25,7 @@ Available Commands:
|
||||||
mv Move a key between (or within) databases.
|
mv Move a key between (or within) databases.
|
||||||
restore Restore key/value pairs from an NDJSON dump
|
restore Restore key/value pairs from an NDJSON dump
|
||||||
set Set a value for a key by passing VALUE or Stdin. Optionally specify a db.
|
set Set a value for a key by passing VALUE or Stdin. Optionally specify a db.
|
||||||
version Show the version of your CLI tool
|
version Display pda! version
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
-h, --help help for pda
|
-h, --help help for pda
|
||||||
|
|
@ -56,7 +56,7 @@ Available Commands:
|
||||||
mv Move a key between (or within) databases.
|
mv Move a key between (or within) databases.
|
||||||
restore Restore key/value pairs from an NDJSON dump
|
restore Restore key/value pairs from an NDJSON dump
|
||||||
set Set a value for a key by passing VALUE or Stdin. Optionally specify a db.
|
set Set a value for a key by passing VALUE or Stdin. Optionally specify a db.
|
||||||
version Show the version of your CLI tool
|
version Display pda! version
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
-h, --help help for pda
|
-h, --help help for pda
|
||||||
|
|
|
||||||
2
testdata/list__err__with__invalid_db.ct
vendored
Normal file
2
testdata/list__err__with__invalid_db.ct
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
$ pda ls foo/bar --> FAIL
|
||||||
|
Error: cannot ls 'foo/bar': cannot parse db: bad db format, use DB or @DB
|
||||||
2
testdata/root__ok.ct
vendored
2
testdata/root__ok.ct
vendored
|
|
@ -24,7 +24,7 @@ Available Commands:
|
||||||
mv Move a key between (or within) databases.
|
mv Move a key between (or within) databases.
|
||||||
restore Restore key/value pairs from an NDJSON dump
|
restore Restore key/value pairs from an NDJSON dump
|
||||||
set Set a value for a key by passing VALUE or Stdin. Optionally specify a db.
|
set Set a value for a key by passing VALUE or Stdin. Optionally specify a db.
|
||||||
version Show the version of your CLI tool
|
version Display pda! version
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
-h, --help help for pda
|
-h, --help help for pda
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue