Repository navigation
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·55 lines (46 loc) · 2.32 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·55 lines (46 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
set -e
# These tests assume a freshly deployed canister with counter starting at 0.
# Run: icp network start -d && icp deploy && bash test.sh
echo "=== Test 1: get_count returns 0 initially ==="
result=$(icp canister call --query backend get_count '(record {})') && \
echo "$result" && \
echo "$result" | grep -q 'count = opt (0' && \
echo "PASS" || (echo "FAIL" && exit 1)
echo "=== Test 2: increment_count returns new_count = 1 ==="
result=$(icp canister call backend increment_count '(record {})') && \
echo "$result" && \
echo "$result" | grep -q 'new_count = opt (1' && \
echo "PASS" || (echo "FAIL" && exit 1)
echo "=== Test 3: get_count returns 1 after increment ==="
result=$(icp canister call --query backend get_count '(record {})') && \
echo "$result" && \
echo "$result" | grep -q 'count = opt (1' && \
echo "PASS" || (echo "FAIL" && exit 1)
echo "=== Test 4: increment_count again returns new_count = 2 ==="
result=$(icp canister call backend increment_count '(record {})') && \
echo "$result" && \
echo "$result" | grep -q 'new_count = opt (2' && \
echo "PASS" || (echo "FAIL" && exit 1)
echo "=== Test 5: decrement_count returns new_count = 1 ==="
result=$(icp canister call backend decrement_count '(record {})') && \
echo "$result" && \
echo "$result" | grep -q 'new_count = opt (1' && \
echo "PASS" || (echo "FAIL" && exit 1)
echo "=== Test 6: get_count returns 1 after decrement ==="
result=$(icp canister call --query backend get_count '(record {})') && \
echo "$result" && \
echo "$result" | grep -q 'count = opt (1' && \
echo "PASS" || (echo "FAIL" && exit 1)
echo "=== Test 7: get_proposal_info with missing proposal_id returns error ==="
result=$(icp canister call backend get_proposal_info '(record { proposal_id = null })') && \
echo "$result" && \
echo "$result" | grep -q 'Missing proposal_id' && \
echo "PASS" || (echo "FAIL" && exit 1)
echo "=== Test 8: get_proposal_titles returns error when NNS Governance is not deployed ==="
# NNS Governance is not deployed in the local test environment; the canister
# should return a graceful error rather than crash.
result=$(icp canister call backend get_proposal_titles '(record { limit = null })') && \
echo "$result" && \
echo "$result" | grep -q 'NNS Governance call failed' && \
echo "PASS" || (echo "FAIL" && exit 1)