cleaning up set handlers, eliminating 2nd level demultiplexing and improving use...
[oweals/gnunet.git] / src / auction / test_auction_create.sh
1 #! /bin/sh
2
3 trap 'rm -f test.json' EXIT
4
5
6 # missing required cmdline args
7 gnunet-auction-create      -r 1 -d foo -p test.json && exit 1
8 gnunet-auction-create -s 1      -d foo -p test.json && exit 1
9 gnunet-auction-create -s 1 -r 1        -p test.json && exit 1
10 gnunet-auction-create -s 1 -r 1 -d foo              && exit 1
11
12
13 # no pricemap
14 rm -f test.json
15 gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
16
17
18 # json errors
19 cat <<DOG >test.json
20 [,]
21 DOG
22 gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
23
24 cat <<DOG >test.json
25 bla
26 DOG
27 gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
28
29
30 # unexpected structures
31 cat <<DOG >test.json
32 {"foo": "bar"}
33 DOG
34 gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
35
36 cat <<DOG >test.json
37 {"currency": "foo"}
38 DOG
39 gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
40
41 cat <<DOG >test.json
42 {"prices": []}
43 DOG
44 gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
45
46 cat <<DOG >test.json
47 {"currency": "foo", "prices": "bar"}
48 DOG
49 gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
50
51
52 # wrong array content
53 cat <<DOG >test.json
54 {"currency": "foo", "prices": []}
55 DOG
56 gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
57
58 cat <<DOG >test.json
59 {"currency": "foo", "prices": ["bar"]}
60 DOG
61 gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
62
63 cat <<DOG >test.json
64 {"currency": "foo", "prices": [null]}
65 DOG
66 gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
67
68 cat <<DOG >test.json
69 {"currency": "foo", "prices": [1, 2]}
70 DOG
71 gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
72
73
74 # correct example
75 cat <<DOG >test.json
76 {"currency": "foo", "prices": [2, 1]}
77 DOG
78 gnunet-auction-create -s 1 -r 1 -d foo -p test.json || exit 1
79
80 rm -f test.json