nuno gist felülvizsgálása 1 month ago. Revízióhoz ugrás
1 file changed, 21 insertions
gistfile1.txt(fájl létrehozva)
| @@ -0,0 +1,21 @@ | |||
| 1 | + | function cmd::test::unit_json_output() { | |
| 2 | + | test::section "Unit: JSON output" | |
| 3 | + | ||
| 4 | + | command::_load_mixins 2>/dev/null || true | |
| 5 | + | ||
| 6 | + | # json::envelope produces valid structure | |
| 7 | + | local result | |
| 8 | + | result=$(echo '{"peers":[]}' | json::envelope "list" "0") | |
| 9 | + | cmd::test::assert "envelope ok field" "$(echo "$result" | grep -o '"ok":true')" '"ok":true' | |
| 10 | + | cmd::test::assert "envelope command field" "$(echo "$result" | grep -o '"command":"list"')" '"command":"list"' | |
| 11 | + | cmd::test::assert "envelope meta field" "$(echo "$result" | grep -o '"meta":')" '"meta":' | |
| 12 | + | cmd::test::assert "envelope count field" "$(echo "$result" | grep -o '"count":0')" '"count":0' | |
| 13 | + | ||
| 14 | + | # command::mixin registration | |
| 15 | + | load_command list | |
| 16 | + | cmd::test::assert_true "json_output mixin registered" "declare -f command::mixin::json_output::register >/dev/null 2>&1" | |
| 17 | + | cmd::test::assert_true "command::json accessor exists" "declare -f command::json >/dev/null 2>&1" | |
| 18 | + | ||
| 19 | + | # json::error_envelope | |
| 20 | + | local err_result | |
| 21 | + | err_result=$(json::error_envelope "inspect" "Peer not found") | |
Újabb
Régebbi