Skip to content

Commit 77c5962

Browse files
committed
Added test for replace_version
Signed-off-by: Ole Herman Schumacher Elgesem <ole.elgesem@northern.tech>
1 parent b6c71d5 commit 77c5962

4 files changed

Lines changed: 48 additions & 0 deletions

File tree

tests/shell/043_replace_version.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
set -e
2+
set -x
3+
cd tests/
4+
mkdir -p ./tmp/
5+
cd ./tmp/
6+
7+
# Set up the project we will build:
8+
cp ../shell/043_replace_version/example-cfbs.json ./cfbs.json
9+
mkdir -p subdir
10+
cp ../shell/043_replace_version/subdir/example.py ./subdir/example.py
11+
12+
# Before building, version number is 0.0.0:
13+
grep 'print("Version: 0.0.0")' ./subdir/example.py
14+
! grep 'print("Version: 1.2.3")' ./subdir/example.py
15+
16+
cfbs build
17+
18+
# After building, input and output should be different:
19+
! diff ./subdir/example.py ./out/masterfiles/services/cfbs/subdir/example.py
20+
21+
# Check that version number is correct in output:
22+
grep 'print("Version: 1.2.3")' ./out/masterfiles/services/cfbs/subdir/example.py
23+
! grep 'print("Version: 0.0.0")' ./out/masterfiles/services/cfbs/subdir/example.py
24+
25+
# Also check that the input was not modified:
26+
grep 'print("Version: 0.0.0")' ./subdir/example.py
27+
! grep 'print("Version: 1.2.3")' ./subdir/example.py
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "Example project",
3+
"description": "Example description",
4+
"type": "policy-set",
5+
"git": true,
6+
"build": [
7+
{
8+
"name": "./subdir/",
9+
"description": "Local subdirectory added using cfbs command line",
10+
"added_by": "cfbs add",
11+
"version": "1.2.3",
12+
"steps": [
13+
"copy example.py services/cfbs/subdir/example.py",
14+
"replace_version services/cfbs/subdir/example.py 0.0.0"
15+
]
16+
}
17+
]
18+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
if __name__ == "__main__":
2+
print("Version: 0.0.0")

tests/shell/all.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,6 @@ bash tests/shell/039_add_added_by_field_update_1.sh
4646
bash tests/shell/040_add_added_by_field_update_2.sh
4747
bash tests/shell/041_add_multidep.sh
4848
bash tests/shell/042_update_from_url.sh
49+
bash tests/shell/043_replace_version.sh
4950

5051
echo "All cfbs shell tests completed successfully!"

0 commit comments

Comments
 (0)