#######################################################
#
# Append field, different value_separator
#
#######################################################
body common control
{
  inputs => { "../../default.sub.cf" };
  bundlesequence => { default("$(this.promise_filename)") };
  version => "1.0";
}

#######################################################
bundle agent init
{
  vars:
    "states" slist => { "actual", "expected" };

    "actual"
      string => "able:baker,booker,banker:charlie:delta:echo
apple:banana:carrot:dogfood
aardvark:baboon:colugo:dingo::fox
ampallang:: :dydoe:,:::::
:blowfish:conger:dogfish:eel:flounder";

    "expected"
      string => "able:baker,booker,banker+XXX:charlie:delta:echo
apple:banana+XXX:carrot:dogfood
aardvark:baboon+XXX:colugo:dingo::fox
ampallang:XXX: :dydoe:,:::::
:blowfish:conger:dogfish:eel:flounder";

  files:
    "$(G.testfile).$(states)"
      create => "true",
      edit_line => init_insert("$(init.$(states))"),
      edit_defaults => init_empty;
}

bundle edit_line init_insert(str)
{
  insert_lines:
    "$(str)";
}

body edit_defaults init_empty
{
  empty_file_before_editing => "true";
}

#######################################################
bundle agent test
{
  files:
    "$(G.testfile).actual" edit_line => test_edit;
}

bundle edit_line test_edit
{
  field_edits:
    "a.*" edit_field => test_col;
}

body edit_field test_col
{
  allow_blank_fields => "true";
  extend_fields => "true";
  field_operation => "append";
  field_separator => ":";
  field_value => "XXX";
  select_field => "2";
  start_fields_from_zero => "false";
  value_separator => "+";
}

#######################################################
bundle agent check
{
  methods:
    "any"
      usebundle => dcs_check_diff(
        "$(G.testfile).actual",
        "$(G.testfile).expected",
        "$(this.promise_filename)"
      );
}

### PROJECT_ID: core
### CATEGORY_ID: 27
