File: manage_variable_values_ini.cf

package info (click to toggle)
cfengine3 3.24.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,552 kB
  • sloc: ansic: 163,161; sh: 10,296; python: 2,950; makefile: 1,744; lex: 784; yacc: 633; perl: 211; pascal: 157; xml: 21; sed: 13
file content (82 lines) | stat: -rw-r--r-- 2,633 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#######################################################
#
# Test manage_variable_values_ini
#
#######################################################

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

bundle agent init
{
  vars:
      "expectations" string => ifelse( "cfengine_3_10", "3.10.x", "" );

  files:
      # The tested file "actual" is copied from our seeded starting position.
      "$(G.testfile).actual"
      copy_from => local_cp("$(this.promise_filename).start");

     # Next we place the file which we will compare the final result with.
     "$(G.testfile).expected"
     copy_from => local_cp("$(this.promise_filename).finish$(expectations)");
}

#######################################################

bundle agent test
{
  meta:
      "description" -> { "CFE-3221", "CFE-3244" }
        string => "Test expected behavior of manage_variable_values_ini";

  vars:
      "config[section][keyone]" string => "1";
      "config[section][keytwo]" string => "valuetwo";

      "config[CFE-3221][variablename]" string => "desired value";
      "config[CFE-3221][variablename2]" string => "desired value2";
      "config[CFE-3221][variablename3]" string => "desired value3";
      "config[CFE-3221][variablename4]" string => "desired value4";
      "config[CFE-3221][variablename5]" string => "desired value5";
      "config[CFE-3221][variablename6]" string => "desired value6";
      "config[CFE-3221][variablename7]" string => "desired value7";
      "config[CFE-3221][variablename8]" string => "desired value8";
      "config[CFE-3244][keyone]" string => "1";
      "config[CFE-3244][keytwo]" string => "valuetwo";

  files:
      "$(G.testfile).actual"
      edit_line => manage_variable_values_ini( "test.config", "section" );

      "$(G.testfile).actual" -> { "CFE-3221" }
        edit_line => manage_variable_values_ini( "test.config", "CFE-3221" );

      "$(G.testfile).actual" -> { "CFE-3244" }
        edit_line => manage_variable_values_ini( "test.config", "CFE-3244" );

}

#######################################################

bundle agent check
{
  methods:
      "check"
      usebundle => dcs_if_diff( "$(G.testfile).actual", "$(G.testfile).expected",
                                "pass", "_fail");
      # Fail the test if any of the files fail.

      "fail"
        usebundle => dcs_fail( $(this.promise_filename) ),
        if => "_fail";

    pass::
      "pass"
        usebundle => dcs_pass( $(this.promise_filename) );
}