test_auction_create.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #! /bin/sh
  2. trap 'rm -f test.json' EXIT
  3. # missing required cmdline args
  4. gnunet-auction-create -r 1 -d foo -p test.json && exit 1
  5. gnunet-auction-create -s 1 -d foo -p test.json && exit 1
  6. gnunet-auction-create -s 1 -r 1 -p test.json && exit 1
  7. gnunet-auction-create -s 1 -r 1 -d foo && exit 1
  8. # no pricemap
  9. rm -f test.json
  10. gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
  11. # json errors
  12. cat <<DOG >test.json
  13. [,]
  14. DOG
  15. gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
  16. cat <<DOG >test.json
  17. bla
  18. DOG
  19. gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
  20. # unexpected structures
  21. cat <<DOG >test.json
  22. {"foo": "bar"}
  23. DOG
  24. gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
  25. cat <<DOG >test.json
  26. {"currency": "foo"}
  27. DOG
  28. gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
  29. cat <<DOG >test.json
  30. {"prices": []}
  31. DOG
  32. gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
  33. cat <<DOG >test.json
  34. {"currency": "foo", "prices": "bar"}
  35. DOG
  36. gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
  37. # wrong array content
  38. cat <<DOG >test.json
  39. {"currency": "foo", "prices": []}
  40. DOG
  41. gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
  42. cat <<DOG >test.json
  43. {"currency": "foo", "prices": ["bar"]}
  44. DOG
  45. gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
  46. cat <<DOG >test.json
  47. {"currency": "foo", "prices": [null]}
  48. DOG
  49. gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
  50. cat <<DOG >test.json
  51. {"currency": "foo", "prices": [1, 2]}
  52. DOG
  53. gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
  54. # correct example
  55. cat <<DOG >test.json
  56. {"currency": "foo", "prices": [2, 1]}
  57. DOG
  58. gnunet-auction-create -s 1 -r 1 -d foo -p test.json || exit 1
  59. rm -f test.json