1# Test that the bundlestate() function gives good data
2
3body common control
4{
5      inputs => { "../../default.cf.sub", "bundlestate.cf.sub" };
6      bundlesequence => { default("$(this.promise_filename)") };
7      version => "1.0";
8}
9
10bundle agent init
11{
12  vars:
13      "s" string => "Hello!";
14      "d" data => parsejson('[4,5,6]');
15      "list" slist => { "element1", "element2" };
16      "h" data => parsejson('{ "a": "x", "b": "y"}');
17
18  methods:
19      "" usebundle => external:init;
20      "" usebundle => external:dump;
21}
22
23bundle agent test
24{
25  vars:
26      "holder" data => bundlestate("init");
27      "holder2" data => bundlestate("$(this.namespace):init");
28      "holder3" data => bundlestate("nosuchnamespace:init");
29      "holder4" data => bundlestate("external:init");
30
31      "holder_s" string => format("%S", holder);
32      "holder2_defined" string => ifelse(isvariable(holder2), "we have holder 2 and we shouldn't", "");
33      "holder3_defined" string => ifelse(isvariable("holder3"), "we have holder 3 and we shouldn't", "");
34      "holder4_s" string => format("%S", holder4);
35
36      "s_s" string => format("%S", "holder[s]");
37      "s_d" string => format("%S", "holder[d]");
38      "s_list" string => format("%S", "holder[list]");
39      "s_h" string => format("%S", "holder[h]");
40}
41
42bundle agent check
43{
44  methods:
45      "check" usebundle => dcs_check_strcmp("$(test.s_s)
46$(test.s_d)
47$(test.s_list)
48$(test.s_h)
49$(test.holder4_s)
50$(external:dump.external_holder_s)
51$(external:dump.external_holder2_s)
52$(test.holder2_defined)
53$(test.holder3_defined)",
54                                           '"Hello!"
55[4,5,6]
56["element1","element2"]
57{"a":"x","b":"y"}
58{"external_s":"External Hello!"}
59$(test.holder_s)
60{"external_s":"External Hello!"}
61
62',
63                                           $(this.promise_filename),
64                                           "no");
65}
66