File: set_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 (86 lines) | stat: -rw-r--r-- 2,388 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
83
84
85
86
#######################################################
#
# Test bundle set_config_values_ini
#
#######################################################

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

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

bundle agent init
{
  files:

      "$(G.testfile).actual"
        copy_from => local_cp("$(this.promise_filename).start");


      "$(G.testfile).expected"
        copy_from => local_cp("$(this.promise_filename).finish");

}

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

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

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

      "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 => set_variable_values_ini("test.config", "section");

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

      "$(G.testfile).actual" -> { "CFE-3244" }
        edit_line => set_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) );

}