File: setop_unique_difference_intersection.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 (66 lines) | stat: -rw-r--r-- 2,161 bytes parent folder | download | duplicates (6)
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
#######################################################
#
# Test unique(), difference() and intersection()
#
#######################################################

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

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

bundle agent init
{
  vars:
      "a" slist => { "x", "y", "z" };
      "b" slist => { "100", "9", "10" };
      "c" slist => { };
      "d" slist => { "" };
      "e" slist => { "x" };
      "f" slist => {
                        1,2,3,
                        "one", "two", "three",
                        "long string",
                        "four", "fix", "six",
                        "one", "two", "three",
      };
}

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

bundle agent test
{
  vars:
      "list1" slist => { "a", "b", "c", "d", "e", "f" };
      "list2" slist => { "a", "b", "c", "d", "e", "f" };

      "unique_$(list1)" slist => unique("init.$(list1)");
      "difference_$(list1)_$(list2)" slist => difference("init.$(list1)",
                                                         "init.$(list2)");

      "intersection_$(list1)_$(list2)" slist => intersection("init.$(list1)",
                                                             "init.$(list2)");

      "unique_inline_array" slist => unique('[ "one", "b", "one", "q" ]');
      "unique_inline_object" slist => unique('{ "one": "b", "c": "q", "d": "one" }');

      "difference_inline_$(list1)" slist => difference('[ "one", "b", "one", "q" ]',
                                                      "init.$(list2)");

      "intersection_$(list1)_inline" slist => intersection("init.$(list1)",
                                                          '[ "one", "b", "one", "q" ]');
}

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

bundle agent check
{
  methods:
      "check"  usebundle => dcs_check_state(test,
                                           "$(this.promise_filename).expected.json",
                                           $(this.promise_filename));
}