|
| 1 | +###################################################### |
| 2 | +# |
| 3 | +# Test that attribute with works with custom promise types |
| 4 | +# |
| 5 | +##################################################### |
| 6 | +body common control |
| 7 | +{ |
| 8 | + inputs => { "../default.cf.sub" }; |
| 9 | + bundlesequence => { default("$(this.promise_filename)") }; |
| 10 | + version => "1.0"; |
| 11 | +} |
| 12 | + |
| 13 | +####################################################### |
| 14 | + |
| 15 | +bundle common version_check |
| 16 | +{ |
| 17 | + classes: |
| 18 | + "python_version_compatible_with_cfengine_library" |
| 19 | + expression => returnszero("/usr/bin/python3 -c 'import sys; assert sys.version_info >= (3,6)'", "useshell"); |
| 20 | +@if minimum_version(3.18.1) |
| 21 | + "custom_promises_supports_with" expression => "any"; |
| 22 | +@endif |
| 23 | +} |
| 24 | + |
| 25 | +bundle agent init |
| 26 | +{ |
| 27 | + meta: |
| 28 | + "test_skip_unsupported" string => "!custom_promises_supports_with|!python_version_compatible_with_cfengine_library"; |
| 29 | + |
| 30 | + files: |
| 31 | + "$(G.testfile)" |
| 32 | + delete => init_delete; |
| 33 | + |
| 34 | + "$(this.promise_dirname)/cfengine.py" |
| 35 | + copy_from => local_cp("$(this.promise_dirname)/../../../modules/promises/cfengine.py"); |
| 36 | +} |
| 37 | + |
| 38 | +body delete init_delete |
| 39 | +{ |
| 40 | + dirlinks => "delete"; |
| 41 | + rmdirs => "true"; |
| 42 | +} |
| 43 | + |
| 44 | +####################################################### |
| 45 | + |
| 46 | +@if minimum_version(3.18.1) |
| 47 | +promise agent append |
| 48 | +{ |
| 49 | + interpreter => "/usr/bin/python3"; |
| 50 | + path => "$(this.promise_dirname)/append_promises.py"; |
| 51 | +} |
| 52 | + |
| 53 | +bundle agent test |
| 54 | +{ |
| 55 | + meta: |
| 56 | + "description" -> { "CFE-3438" } |
| 57 | + string => "Test that depends_on works with custom promise types"; |
| 58 | + |
| 59 | + vars: |
| 60 | + "letters" |
| 61 | + slist => { "A", "B", "C", "D", "E", "F" }; |
| 62 | + |
| 63 | + append: |
| 64 | + "$(G.testfile)" |
| 65 | + string => "$(with)", |
| 66 | + with => string_downcase("$(letters)"); |
| 67 | +} |
| 68 | +@endif |
| 69 | + |
| 70 | +####################################################### |
| 71 | + |
| 72 | +bundle agent check |
| 73 | +{ |
| 74 | + vars: |
| 75 | + "expected" |
| 76 | + string => "abcdef"; |
| 77 | + "found" |
| 78 | + string => readfile("$(G.testfile)"); |
| 79 | + |
| 80 | + classes: |
| 81 | + "ok" |
| 82 | + expression => strcmp("$(expected)", "$(found)"); |
| 83 | + |
| 84 | + reports: |
| 85 | + DEBUG:: |
| 86 | + "Expected '$(expected)', found '$(found)'"; |
| 87 | + ok:: |
| 88 | + "$(this.promise_filename) Pass"; |
| 89 | + !ok:: |
| 90 | + "$(this.promise_filename) FAIL"; |
| 91 | +} |
0 commit comments