diff options
| author | Egor Tensin <egor@tensin.name> | 2026-09-29 23:44:16 +0500 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-09-29 23:45:40 +0500 |
| commit | eec673b5c0122e359bf00b0136783a32e8a77df9 (patch) | |
| tree | 61457ccf0d65331f1411b28aa7ba2ad964191ba2 /test/tst-mutuals.sh | |
| parent | remove annoying trailing period from repo URLs (diff) | |
| download | vk-scripts-1.2.0.tar.gz vk-scripts-1.2.0.zip | |
test: rework using the approach from my other projectsv1.2.0
The tests are now run using a framework common to my other projects,
like config-links & tag-release.
Diffstat (limited to 'test/tst-mutuals.sh')
| -rw-r--r-- | test/tst-mutuals.sh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/tst-mutuals.sh b/test/tst-mutuals.sh new file mode 100644 index 0000000..3f40780 --- /dev/null +++ b/test/tst-mutuals.sh @@ -0,0 +1,38 @@ +test_run() { + test_setup + + local users=(kreed58 korya_mc) + + test_run_module vk.mutuals --format csv "${users[@]}" > "$test_root_dir/mutuals.csv" + test_run_module vk.mutuals --format json "${users[@]}" > "$test_root_dir/mutuals.json" + + local expected=10 + + local actual_csv + actual_csv="$( cat -- "$test_root_dir/mutuals.csv" | wc -l )" + log "Mutuals in CSV: $actual_csv" + + if [ "$actual_csv" -lt "$expected" ]; then + fail "Expected a lot more mutual friends in CSV output" + fail_details "Expected: $expected" + fail_details "Actual: $actual_csv" + return 1 + fi + + local actual_json + actual_json="$( grep -F -- '"id":' "$test_root_dir/mutuals.json" | wc -l )" + log "Mutuals in JSON: $actual_json" + + if [ "$actual_json" -lt "$expected" ]; then + fail "Expected a lot more mutual friends in JSON output" + fail_details "Expected: $expected" + fail_details "Actual: $actual_json" + return 1 + fi + + if [ "$actual_csv" -ne "$actual_json" ]; then + fail "Number of mutuals in CSV unequal to that in JSON" + fail_details "Can technically happen, because it's kind of a race" + return 1 + fi +} |
