Skip to content

Commit e9af3cd

Browse files
committed
Add kuttl-insert-test.sh to aid adding new test cases in kuttl tests
1 parent 8f7954e commit e9af3cd

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

kuttl-insert-test.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
#
3+
# This script inserts a blank space into kuttl test list
4+
# (id's of test cases including and after requested will be increased)
5+
6+
# Check if argument is provided
7+
if [ -z "$1" ]
8+
then
9+
echo "Please provide a number of test case which number should be increased."
10+
exit 1
11+
fi
12+
13+
# Loop through the files in descending order and rename them
14+
for file in $(ls -v -r [0-9][0-9]-*)
15+
do
16+
# Get the number from the beginning of the filename
17+
number=$(echo "$file" | cut -d '-' -f 1)
18+
19+
# Check if the number is greater than or equal to the argument
20+
if [ "$number" -ge "$1" ]
21+
then
22+
# Increase the number by 1 and rename the file
23+
new_number=$(expr "$number" + 1)
24+
new_number_padded=$(printf "%02d" "$new_number")
25+
new_file=$(echo "$file" | sed "s/^$number-/$new_number_padded-/")
26+
mv "$file" "$new_file"
27+
fi
28+
done

0 commit comments

Comments
 (0)