2
0

090_cli_options 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. test_add_delta() {
  2. local new_savedir="$TMP_DIR/new_savedir"
  3. local config_delta="$CONFIG_DIR/delta"
  4. local cmdoutput
  5. # add normal changes
  6. touch "$config_delta"
  7. $UCI set delta.sec0=sectype
  8. $UCI add_list delta.sec0.li0=0
  9. # save new changes in "$new_savedir"
  10. mkdir -p "$new_savedir"
  11. touch "$new_savedir/delta"
  12. $UCI -P "$new_savedir" set delta.sec0=sectype
  13. $UCI -P "$new_savedir" add_list delta.sec0.li0=1
  14. assertEquals "delta.sec0='sectype'
  15. delta.sec0.li0+='0'" "$($UCI changes)"
  16. # check combined changes. Order matters here.
  17. cmdoutput="$($UCI -P "$new_savedir" changes)"
  18. assertTrue "$?"
  19. assertEquals "delta.sec0='sectype'
  20. delta.sec0.li0+='0'
  21. delta.sec0='sectype'
  22. delta.sec0.li0+='1'" "$cmdoutput"
  23. # check combined export. Order matters here.
  24. cmdoutput="$($UCI -P "$new_savedir" export)"
  25. assertTrue "$?"
  26. assertEquals "$(cat $REF_DIR/cli.options.delta.export.result)" "$cmdoutput"
  27. # check CLI_FLAG_NOCOMMIT with -P option.
  28. $UCI -P "$new_savedir" commit
  29. assertTrue "$?"
  30. assertEquals "" "$(cat $config_delta)"
  31. # check normal commit.
  32. $UCI -p "$new_savedir" commit
  33. assertTrue "$?"
  34. assertSameFile "$REF_DIR/cli.options.delta.commit.result" "$config_delta"
  35. rm -rf "$new_savedir"
  36. rm -f "$config_delta"
  37. }