2
0

080_list 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. prepare_list_test() {
  2. touch ${CONFIG_DIR}/list_test_config
  3. ${UCI} set list_test_config.SEC0=section
  4. ${UCI} add_list list_test_config.SEC0.list0=value0
  5. ${UCI} add_list list_test_config.SEC0.list0='"Hello
  6. ,'" world\""
  7. }
  8. test_add_list_config() {
  9. prepare_list_test
  10. ${UCI} commit
  11. assertSameFile "${REF_DIR}/add_list_config.result" "$CONFIG_DIR/list_test_config"
  12. }
  13. test_add_list_get() {
  14. # To maintain compatibility with current code, do not quote
  15. # list values that do not contain blank spaces ("\x20\t\r\n") within it.
  16. prepare_list_test
  17. value_list_get=$(${UCI} get list_test_config.SEC0.list0)
  18. assertEquals "$value_list_get" "value0 '\"Hello
  19. , world\"'"
  20. }
  21. test_add_list_show() {
  22. prepare_list_test
  23. value_list_show=$(${UCI} show list_test_config)
  24. value_list_show_ref=$(cat "$REF_DIR/add_list_show.result")
  25. assertEquals "$value_list_show" "$value_list_show_ref"
  26. }
  27. test_add_list_changes() {
  28. prepare_list_test
  29. value_list_changes=$(${UCI} changes)
  30. value_list_changes_ref=$(cat "$REF_DIR/add_list_changes.result")
  31. assertEquals "$value_list_changes" "$value_list_changes_ref"
  32. }
  33. test_del_list() {
  34. prepare_list_test
  35. ${UCI} commit
  36. ${UCI} del_list list_test_config.SEC0.list0=value0
  37. ${UCI} commit
  38. assertSameFile "${REF_DIR}/del_list_config.result" "$CONFIG_DIR/list_test_config"
  39. }
  40. test_del_list_multiline() {
  41. prepare_list_test
  42. ${UCI} commit
  43. ${UCI} del_list list_test_config.SEC0.list0='"Hello
  44. ,'' world"'
  45. ${UCI} commit
  46. assertSameFile "${REF_DIR}/del_list_multiline_config.result" "$CONFIG_DIR/list_test_config"
  47. }