Skip to content

Commit 4ff81a5

Browse files
committed
Renamed assert_file_matches() to assert_file_matches_regex()
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent fa37d9d commit 4ff81a5

4 files changed

Lines changed: 24 additions & 24 deletions

File tree

tests/shell/011_update.sh

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,31 @@ cfbs --non-interactive update
1111
# Also, it should not break on new commits(!)
1212
# TODO: Use jq, a python script, cfbs validate or something similar
1313

14-
assert_file_matches cfbs.json '"name".*"Example'
15-
assert_file_matches cfbs.json '"type".*"policy-set"'
16-
assert_file_matches cfbs.json '"description".*"Example description"'
14+
assert_file_matches_regex cfbs.json '"name".*"Example'
15+
assert_file_matches_regex cfbs.json '"type".*"policy-set"'
16+
assert_file_matches_regex cfbs.json '"description".*"Example description"'
1717

18-
assert_file_matches cfbs.json '"name".*"promise-type-ansible"'
19-
assert_file_matches cfbs.json '"version":.*[0-9]+\.[0-9]+'
18+
assert_file_matches_regex cfbs.json '"name".*"promise-type-ansible"'
19+
assert_file_matches_regex cfbs.json '"version":.*[0-9]+\.[0-9]+'
2020
assert_file_contains cfbs.json '"commit"'
21-
assert_file_matches cfbs.json '"added_by".*"cfbs add"'
21+
assert_file_matches_regex cfbs.json '"added_by".*"cfbs add"'
2222
assert_file_contains cfbs.json '"steps"'
2323
assert_file_contains cfbs.json 'copy ansible_promise.py modules/promises/'
2424
assert_file_contains cfbs.json 'append enable.cf services/init.cf'
25-
assert_file_matches cfbs.json '"tags".*"supported"'
26-
assert_file_matches cfbs.json '"by".*"https://github.com/tranchitella"'
27-
assert_file_matches cfbs.json '"repo".*"https://github.com/cfengine/modules"'
28-
assert_file_matches cfbs.json '"subdirectory".*"promise-types/ansible"'
29-
assert_file_matches cfbs.json '"dependencies".*"library-for-promise-types-in-python"'
30-
assert_file_matches cfbs.json '"description".*"Promise type to run ansible playbooks'
31-
32-
assert_file_matches cfbs.json '"name".*"library-for-promise-types-in-python"'
33-
assert_file_matches cfbs.json '"description".*"Library enabling promise types implemented in python'
34-
assert_file_matches cfbs.json '"tags".*"library"'
35-
assert_file_matches cfbs.json '"repo".*"https://github.com/cfengine/modules"'
36-
assert_file_matches cfbs.json '"by".*"https://github.com/cfengine"'
37-
assert_file_matches cfbs.json '"subdirectory".*"libraries/python"'
38-
assert_file_matches cfbs.json '"added_by".*"promise-type-ansible"'
25+
assert_file_matches_regex cfbs.json '"tags".*"supported"'
26+
assert_file_matches_regex cfbs.json '"by".*"https://github.com/tranchitella"'
27+
assert_file_matches_regex cfbs.json '"repo".*"https://github.com/cfengine/modules"'
28+
assert_file_matches_regex cfbs.json '"subdirectory".*"promise-types/ansible"'
29+
assert_file_matches_regex cfbs.json '"dependencies".*"library-for-promise-types-in-python"'
30+
assert_file_matches_regex cfbs.json '"description".*"Promise type to run ansible playbooks'
31+
32+
assert_file_matches_regex cfbs.json '"name".*"library-for-promise-types-in-python"'
33+
assert_file_matches_regex cfbs.json '"description".*"Library enabling promise types implemented in python'
34+
assert_file_matches_regex cfbs.json '"tags".*"library"'
35+
assert_file_matches_regex cfbs.json '"repo".*"https://github.com/cfengine/modules"'
36+
assert_file_matches_regex cfbs.json '"by".*"https://github.com/cfengine"'
37+
assert_file_matches_regex cfbs.json '"subdirectory".*"libraries/python"'
38+
assert_file_matches_regex cfbs.json '"added_by".*"promise-type-ansible"'
3939
assert_file_contains cfbs.json 'copy cfengine_module_library.py modules/promises/cfengine_module_library.py'
4040

4141
cfbs status

tests/shell/039_add_added_by_field_update_1.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ test_init
44
cfbs --non-interactive init
55

66
# Ensure adding a module during initialization is treated as adding manually
7-
assert_file_matches cfbs.json '"added_by".*"cfbs init"'
7+
assert_file_matches_regex cfbs.json '"added_by".*"cfbs init"'
88
# TODO: the case of custom non-masterfiles module(s) should also be tested
99

1010
# Manually adding a module then manually adding its dependency should update the latter's `"added_by"` field in `cfbs.json`
1111

1212
cfbs --non-interactive add package-method-winget
13-
assert_file_matches cfbs.json '"added_by".*"package-method-winget"'
13+
assert_file_matches_regex cfbs.json '"added_by".*"package-method-winget"'
1414
assert_count 1 cfbs.json '"cfbs add"'
1515

1616
cfbs --non-interactive add powershell-execution-policy

tests/shell/040_add_added_by_field_update_2.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cfbs --non-interactive init
66
# Manually adding a dependency of a module then manually adding that module should not update the latter's `"added_by"` field in `cfbs.json`
77

88
cfbs --non-interactive add powershell-execution-policy
9-
assert_file_matches cfbs.json '"added_by".*"cfbs add"'
9+
assert_file_matches_regex cfbs.json '"added_by".*"cfbs add"'
1010

1111
cfbs --non-interactive add package-method-winget
1212
assert_file_not_contains cfbs.json '"added_by": "package-method-winget"'

tests/shell/testlib.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ assert_file_not_contains() {
9393
! grep -qF "$2" "$1" || _test_fail "Expected file '$1' to NOT contain: $2"
9494
}
9595

96-
assert_file_matches() {
96+
assert_file_matches_regex() {
9797
grep -qE "$2" "$1" || _test_fail "Expected file '$1' to match regex: $2"
9898
}
9999

0 commit comments

Comments
 (0)