Skip to content

Commit 02338a1

Browse files
committed
Added tests for the functionality of updating by branch
Signed-off-by: jakub-nt <175944085+jakub-nt@users.noreply.github.com>
1 parent ebdf0b7 commit 02338a1

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
set -e
2+
set -x
3+
cd tests/
4+
mkdir -p ./tmp/
5+
cd ./tmp/
6+
touch cfbs.json && rm cfbs.json
7+
rm -rf .git
8+
9+
cfbs --non-interactive init --masterfiles no
10+
cfbs --non-interactive add https://github.com/cfengine/test-cfbs-static-repo/@update-test-branch test-library-parsed-local-users
11+
12+
# check that cfbs.json contains the right commit hash (ideally for testing, different than the default branch's commit hash):
13+
grep '"commit": "2152eb5a39fbf9b051105b400639b436bd53ab87"' cfbs.json
14+
# check that branch key is correctly set:
15+
grep '"branch": "update-test-branch"' cfbs.json
16+
17+
cfbs update test-library-parsed-local-users | grep "Module 'test-library-parsed-local-users' already up to date"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
set -e
2+
set -x
3+
cd tests/
4+
mkdir -p ./tmp/
5+
cd ./tmp/
6+
touch cfbs.json && rm cfbs.json
7+
rm -rf .git
8+
9+
cfbs --non-interactive init --masterfiles no
10+
cfbs --non-interactive add https://github.com/cfengine/test-cfbs-static-repo/@update-test-branch test-library-parsed-local-users
11+
12+
cp ../shell/046_update_from_url_branch/cfbs.json .
13+
14+
cfbs update test-library-parsed-local-users | grep "Updated module 'test-library-parsed-local-users' from url"
15+
# check that the commit hash changed:
16+
grep '"commit": "2152eb5a39fbf9b051105b400639b436bd53ab87"' cfbs.json
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "Example project",
3+
"description": "Example description",
4+
"type": "policy-set",
5+
"git": true,
6+
"build": [
7+
{
8+
"name": "test-library-parsed-local-users",
9+
"description": "Parse local users from /etc/passwd on the system with their attributes from /etc/shadow",
10+
"url": "https://github.com/cfengine/test-cfbs-static-repo/",
11+
"commit": "f702461f319e170db05bcb61f867b440b5cbd013",
12+
"branch": "update-test-branch",
13+
"subdirectory": "test_library_parsed_etc_passwd_shadow",
14+
"added_by": "cfbs add",
15+
"steps": [
16+
"copy ./test_library_parsed_etc_passwd_shadow.cf services/local-users/test_library_parsed_etc_passwd_shadow/",
17+
"json cfbs/def.json def.json"
18+
]
19+
}
20+
]
21+
}

tests/shell/all.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,7 @@ bash tests/shell/041_add_multidep.sh
4848
bash tests/shell/042_update_from_url.sh
4949
bash tests/shell/043_replace_version.sh
5050
bash tests/shell/044_replace.sh
51+
bash tests/shell/045_update_from_url_branch_uptodate.sh
52+
bash tests/shell/046_update_from_url_branch.sh
5153

5254
echo "All cfbs shell tests completed successfully!"

0 commit comments

Comments
 (0)