|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -e |
| 3 | + |
| 4 | +echo "=== Test 1: get_count returns 0 initially ===" |
| 5 | +result=$(icp canister call --query backend get_count '(record {})') && \ |
| 6 | + echo "$result" && \ |
| 7 | + echo "$result" | grep -q 'count = opt (0' && \ |
| 8 | + echo "PASS" || (echo "FAIL" && exit 1) |
| 9 | + |
| 10 | +echo "=== Test 2: increment_count returns new_count = 1 ===" |
| 11 | +result=$(icp canister call backend increment_count '(record {})') && \ |
| 12 | + echo "$result" && \ |
| 13 | + echo "$result" | grep -q 'new_count = opt (1' && \ |
| 14 | + echo "PASS" || (echo "FAIL" && exit 1) |
| 15 | + |
| 16 | +echo "=== Test 3: get_count returns 1 after increment ===" |
| 17 | +result=$(icp canister call --query backend get_count '(record {})') && \ |
| 18 | + echo "$result" && \ |
| 19 | + echo "$result" | grep -q 'count = opt (1' && \ |
| 20 | + echo "PASS" || (echo "FAIL" && exit 1) |
| 21 | + |
| 22 | +echo "=== Test 4: increment_count again returns new_count = 2 ===" |
| 23 | +result=$(icp canister call backend increment_count '(record {})') && \ |
| 24 | + echo "$result" && \ |
| 25 | + echo "$result" | grep -q 'new_count = opt (2' && \ |
| 26 | + echo "PASS" || (echo "FAIL" && exit 1) |
| 27 | + |
| 28 | +echo "=== Test 5: decrement_count returns new_count = 1 ===" |
| 29 | +result=$(icp canister call backend decrement_count '(record {})') && \ |
| 30 | + echo "$result" && \ |
| 31 | + echo "$result" | grep -q 'new_count = opt (1' && \ |
| 32 | + echo "PASS" || (echo "FAIL" && exit 1) |
| 33 | + |
| 34 | +echo "=== Test 6: get_count returns 1 after decrement ===" |
| 35 | +result=$(icp canister call --query backend get_count '(record {})') && \ |
| 36 | + echo "$result" && \ |
| 37 | + echo "$result" | grep -q 'count = opt (1' && \ |
| 38 | + echo "PASS" || (echo "FAIL" && exit 1) |
| 39 | + |
| 40 | +echo "=== Test 7: get_proposal_info with missing proposal_id returns error ===" |
| 41 | +result=$(icp canister call backend get_proposal_info '(record { proposal_id = null })') && \ |
| 42 | + echo "$result" && \ |
| 43 | + echo "$result" | grep -q 'Missing proposal_id' && \ |
| 44 | + echo "PASS" || (echo "FAIL" && exit 1) |
| 45 | + |
| 46 | +echo "=== Test 8: get_proposal_titles returns titles list ===" |
| 47 | +result=$(icp canister call backend get_proposal_titles '(record { limit = null })') && \ |
| 48 | + echo "$result" && \ |
| 49 | + echo "$result" | grep -q 'titles' && \ |
| 50 | + echo "PASS" || (echo "FAIL" && exit 1) |
0 commit comments