Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6cedbc9

Browse files
committed
add tests for env param in hooks
Signed-off-by: lfbzhm <lifubang@acmcoder.com>
1 parentc9dcc3d commit6cedbc9

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

‎tests/integration/hooks.bats‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,41 @@ function teardown() {
4242
[["$output"==*"error running$hook hook #1:"* ]]
4343
done
4444
}
45+
46+
@test"runc run [hook with env]" {
47+
update_config'.process.args = ["/bin/true"]'
48+
update_config'.process.env = ["mm=nn"]'
49+
# All hooks except Poststop.
50+
forhookin prestart createRuntime createContainer startContainer poststart;do
51+
echo"testing hook$hook"
52+
# shellcheck disable=SC2016
53+
update_config'.hooks = {
54+
"'$hook'": [{
55+
"path": "/bin/sh",
56+
"args": ["/bin/sh", "-c", "[ \"$mm\"==\"tt\" ] && echo yes, we got tt from the env mm && exit 1 || exit 0"],
57+
"env": ["mm=tt"]
58+
}]
59+
}'
60+
mm=nn runc run"test_hook-$hook"
61+
["$status"-ne 0 ]
62+
[["$output"==*"yes, we got tt from the env mm"* ]]
63+
done
64+
}
65+
66+
@test"runc run [hook without env]" {
67+
update_config'.process.args = ["/bin/true"]'
68+
update_config'.process.env = ["mm=nn"]'
69+
# All hooks except Poststop.
70+
forhookin prestart createRuntime createContainer startContainer poststart;do
71+
echo"testing hook$hook"
72+
# shellcheck disable=SC2016
73+
update_config'.hooks = {
74+
"'$hook'": [{
75+
"path": "/bin/sh",
76+
"args": ["/bin/sh", "-c", "[[ \"$mm\" == \"nn\" ]] && echo \"$mm\" && exit 1 || exit 0"]
77+
}]
78+
}'
79+
mm=nn runc run"test_hook-$hook"
80+
["$status"-eq 0 ]
81+
done
82+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp