Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/shell/035_cfbs_build_compatibility_1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cd ./tmp/
rm -rf ./*

# The purpose of this test is to ensure that older CFEngine Build projects
# still buid in newer versions of cfbs
# still build in newer versions of cfbs

# The below cfbs.json file was generated using cfbs 3.2.7
# which is the cfbs version shipped with CFEngine Enterprise 3.21.0
Expand Down
23 changes: 23 additions & 0 deletions tests/shell/039_add_added_by_field_update_1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set -e
set -x
cd tests/
mkdir -p ./tmp/
cd ./tmp/
touch cfbs.json && rm cfbs.json
rm -rf .git

cfbs --non-interactive init

# Ensure adding a module during initialization is treated as adding manually
cat cfbs.json | grep -F "added_by" | grep -F "cfbs init"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In stead of cat cfbs.json | grep -F "added_by" you could do grep -F "added_by" cfbs.json. Just FYI, no need to change anything

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or grep -E "added_by|cfbs init" cfbs.json

Copy link
Contributor

@larsewi larsewi Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ would match added_by or cfbs init? But I think he wants to look for a line that contains added_by and this line should also contain cfbs init

# TODO: the case of custom non-masterfiles module(s) should also be tested

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

cfbs --non-interactive add package-method-winget
cat cfbs.json | grep -F "added_by" | grep -F "package-method-winget"
[ "$(cat cfbs.json | grep -F "added_by" | grep -F "cfbs add" -c)" -eq 1 ]

cfbs --non-interactive add powershell-execution-policy
! ( cat cfbs.json | grep -F "added_by" | grep -F "package-method-winget" )
[ "$(cat cfbs.json | grep -F "added_by" | grep -F "cfbs add" -c)" -eq 2 ]
17 changes: 17 additions & 0 deletions tests/shell/040_add_added_by_field_update_2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
set -e
set -x
cd tests/
mkdir -p ./tmp/
cd ./tmp/
touch cfbs.json && rm cfbs.json
rm -rf .git

cfbs --non-interactive init

# Manually adding a dependency of a module then manually adding that module should not update the latter's `"added_by"` field in `cfbs.json`

cfbs --non-interactive add powershell-execution-policy
cat cfbs.json | grep -F "added_by" | grep -F "cfbs add"

cfbs --non-interactive add package-method-winget
! ( cat cfbs.json | grep -F "added_by" | grep -F "package-method-winget" )
2 changes: 2 additions & 0 deletions tests/shell/all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,7 @@ bash tests/shell/035_cfbs_build_compatibility_1.sh
bash tests/shell/036_cfbs_build_compatibility_2.sh
bash tests/shell/037_cfbs_validate.sh
bash tests/shell/038_global_dir.sh
bash tests/shell/039_add_added_by_field_update_1.sh
bash tests/shell/040_add_added_by_field_update_2.sh

echo "All cfbs shell tests completed successfully!"