-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #8952: Add generic methods using new package promises
- Loading branch information
Showing
10 changed files
with
1,598 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
case "$1" in | ||
supports-api-version) | ||
echo 1 | ||
;; | ||
get-package-data) | ||
while read line; do | ||
case "$line" in | ||
File=*) | ||
echo PackageType=repo | ||
echo Name=${line#File=} | ||
;; | ||
*) | ||
true | ||
;; | ||
esac | ||
done | ||
;; | ||
list-installed) | ||
while read line; do | ||
case "$line" in | ||
options=*) | ||
OUTPUT=${line#options=} | ||
;; | ||
*) | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
if [ -f "$OUTPUT" ]; then | ||
cat "$OUTPUT" | ||
fi | ||
;; | ||
list-*) | ||
# Drain input. | ||
cat > /dev/null | ||
;; | ||
repo-install) | ||
while read line; do | ||
case "$line" in | ||
options=*) | ||
OUTPUT=${line#options=} | ||
;; | ||
Name=*) | ||
NAME="${line#Name=}" | ||
;; | ||
Version=*) | ||
VERSION="${line#Version=}" | ||
;; | ||
Architecture=*) | ||
ARCHITECTURE="${line#Architecture=}" | ||
;; | ||
*) | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
echo "Name=$NAME" >> "$OUTPUT" | ||
echo "Version=$VERSION" >> "$OUTPUT" | ||
echo "Architecture=$ARCHITECTURE" >> "$OUTPUT" | ||
;; | ||
*) | ||
exit 1 | ||
;; | ||
esac | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
bundle common acc_path | ||
{ | ||
vars: | ||
"root" string => getenv("NCF_TESTS_ACCEPTANCE", 1024); | ||
} | ||
|
||
body common control | ||
{ | ||
inputs => { "${acc_path.root}/default.cf.sub", "${acc_path.root}/default_ncf.cf.sub", "@{ncf_inputs.default_files}" }; | ||
bundlesequence => { configuration, default("${this.promise_filename}") }; | ||
version => "1.0"; | ||
} | ||
|
||
|
||
bundle agent init | ||
{ | ||
files: | ||
"$(sys.workdir)/modules/packages/." | ||
create => "true"; | ||
"$(sys.workdir)/modules/packages/test" | ||
copy_from => local_cp("$(this.promise_dirname)/package.module"), | ||
perms => m("ugo+x"); | ||
} | ||
|
||
|
||
bundle agent test | ||
{ | ||
|
||
methods: | ||
# version | ||
"any" usebundle => package_present("package_1", "", "", "test"); | ||
"any" usebundle => package_present("package_2", "3.3", "", "test"); | ||
"any" usebundle => package_present("package_3", "latest", "", "test"); | ||
"any" usebundle => package_present("package_4", "any", "", "test"); | ||
# architecture | ||
"any" usebundle => package_present("package_5", "", "x86_64", "test"); | ||
"any" usebundle => package_present("package_6", "6.5", "i686", "test"); | ||
"any" usebundle => package_present("package_7", "6.5", "default", "test"); | ||
} | ||
|
||
bundle agent check { | ||
|
||
vars: | ||
"file_diff_test" string => "/usr/bin/diff \"${this.promise_filename}.expected\" \"${sys.workdir}/tmp/TEST.cfengine\""; | ||
|
||
classes: | ||
"ok" expression => returnszero("${file_diff_test}", "useshell"), | ||
ifvarclass => "package_present_package_1_reached"; | ||
|
||
reports: | ||
ok:: | ||
"$(this.promise_filename) Pass"; | ||
!ok:: | ||
"$(this.promise_filename) FAIL"; | ||
|
||
} | ||
|
21 changes: 21 additions & 0 deletions
21
tests/acceptance/30_generic_methods/package_present.cf.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Name=package_1 | ||
Version= | ||
Architecture= | ||
Name=package_2 | ||
Version=3.3 | ||
Architecture= | ||
Name=package_3 | ||
Version= | ||
Architecture= | ||
Name=package_4 | ||
Version= | ||
Architecture= | ||
Name=package_5 | ||
Version= | ||
Architecture=x86_64 | ||
Name=package_6 | ||
Version=6.5 | ||
Architecture=i686 | ||
Name=package_7 | ||
Version=6.5 | ||
Architecture= |
Oops, something went wrong.