1####################################################### 2# 3# Insert lines at the top of file a multi-line header, 4# verify that insertion is convergent - Redmine #1525 5# 6####################################################### 7 8body common control 9{ 10 inputs => { "../../default.cf.sub" }; 11 bundlesequence => { default("$(this.promise_filename)") }; 12 version => "1.0"; 13} 14 15####################################################### 16 17bundle agent init 18{ 19 vars: 20 "header" string => "############### 21### This file is managed by CFEngine 22### Do not update it manually, oh no 23### do not 24###############"; 25 26 files: 27 "$(G.testfile).expected" 28 create => "true", 29 edit_line => insert_header; 30 31 commands: 32 !windows:: 33 "$(G.echo)" 34 args => "\"${init.header}\" > \"$(G.testfile).actual\"", 35 contain => in_shell; 36 windows:: # newlines in shell are not handled properly on Windows... 37 "$(G.printf)" 38 args => '"###############\n### This file is managed by CFEngine\n### Do not update it manually, oh no\n### do not\n###############\n" > "$(G.testfile).actual"', 39 contain => in_shell; 40} 41 42####################################################### 43 44bundle agent test 45{ 46 files: 47 "$(G.testfile).actual" 48 create => "true", 49 edit_line => insert_header; 50} 51 52bundle edit_line insert_header 53{ 54 insert_lines: 55 "${init.header}" 56 location => start, 57 insert_type => "preserve_block"; 58} 59 60 61####################################################### 62 63bundle agent check 64{ 65 methods: 66 "any" usebundle => dcs_check_diff("$(G.testfile).actual", 67 "$(G.testfile).expected", 68 "$(this.promise_filename)"); 69} 70 71### PROJECT_ID: core 72### CATEGORY_ID: 27 73 74