diff --git a/tests/acceptance/30_custom_promise_types/25_top_down_evaluation_custom_promise_types.cf b/tests/acceptance/30_custom_promise_types/25_top_down_evaluation_custom_promise_types.cf new file mode 100644 index 0000000000..10aea0b755 --- /dev/null +++ b/tests/acceptance/30_custom_promise_types/25_top_down_evaluation_custom_promise_types.cf @@ -0,0 +1,52 @@ +body common control +{ + inputs => { "../default.cf.sub" }; + bundlesequence => { "test", "cleanup" }; + evaluation_order => "top_down"; +} + +promise agent dummy +{ + path => "$(this.promise_dirname)/dummy_promise_type.py"; + interpreter => "/usr/bin/python3"; +} + +bundle agent test +{ + + dummy: + "/tmp/dummyfile" + smth => "hello"; + + vars: + "content" + string => readfile("/tmp/dummyfile"); + + files: + "/tmp/dummyfile" + content => "ok"; + + vars: + "content" + string => readfile("/tmp/dummyfile"); + + classes: + "ok" + expression => strcmp("$(content)", "ok"); + + reports: + ok:: + "$(this.promise_filename) Pass"; + !ok:: + "$(this.promise_filename) FAIL"; + + DEBUG:: + "$(content)"; +} + +bundle agent cleanup +{ + files: + "/tmp/dummyfile" + delete => tidy; +} diff --git a/tests/acceptance/30_custom_promise_types/dummy_promise_type.py b/tests/acceptance/30_custom_promise_types/dummy_promise_type.py new file mode 100644 index 0000000000..9e7be71d17 --- /dev/null +++ b/tests/acceptance/30_custom_promise_types/dummy_promise_type.py @@ -0,0 +1,26 @@ +from cfengine import ( + PromiseModule, + Result, +) + + +class DummyPromiseType(PromiseModule): + + def __init__(self, **kwargs): + super(DummyPromiseType, self).__init__( + name="dummy_promise_module", version="0.0.0", **kwargs + ) + + def validate_promise(self, promiser, attributes, meta): + pass + + def evaluate_promise(self, promiser, attributes, metadata): + + with open(promiser, "a") as f: + f.write("test") + + return Result.KEPT + + +if __name__ == "__main__": + DummyPromiseType().start()