Compare commits
2 Commits
4c25741089
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 93eeb4ef26 | |||
| 11d826f896 |
26
README.md
Normal file
26
README.md
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# DevOps Bash Tests
|
||||||
|
|
||||||
|
## Descriere
|
||||||
|
Acest proiect conține o aplicație simplă (`calculator.sh`), teste automate și un script DevOps (`run_tests.sh`) care rulează toate testele.
|
||||||
|
|
||||||
|
## Structură
|
||||||
|
- `app/` – codul aplicației
|
||||||
|
- `tests/` – teste automate
|
||||||
|
- `run_tests.sh` – scriptul principal care rulează toate testele
|
||||||
|
|
||||||
|
## Cum rulezi testele manual
|
||||||
|
1. Deschide terminalul în directorul proiectului
|
||||||
|
2. Fă scripturile executabile:
|
||||||
|
```bash
|
||||||
|
chmod +x run_tests.sh tests/*.sh app/*.sh
|
||||||
|
|
||||||
|
## Ruleaza testele
|
||||||
|
./run_tests.sh
|
||||||
|
|
||||||
|
## Cum funcționează
|
||||||
|
|
||||||
|
- Scriptul parcurge toate testele din folderul tests/
|
||||||
|
- Rulează fiecare test
|
||||||
|
- Afișează PASS/FAIL
|
||||||
|
- Returnează codul 0 dacă toate testele au trecut, 1 dacă cel puțin un test a eșuat
|
||||||
|
|
||||||
6
app/calculator.sh
Executable file
6
app/calculator.sh
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
add() {
|
||||||
|
echo $(($1+$2))
|
||||||
|
}
|
||||||
|
|
||||||
29
run_tests.sh
Executable file
29
run_tests.sh
Executable file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Pornesc rularea testelor..."
|
||||||
|
|
||||||
|
FAILED=0
|
||||||
|
|
||||||
|
for test in tests/*.sh; do
|
||||||
|
echo "Rulez $test"
|
||||||
|
bash "$test"
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
FAILED=1
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
if [ $FAILED -eq 0 ]; then
|
||||||
|
echo "Toate testele au trecut"
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "Unele teste au esuat"
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
19
tests/test_calculator.sh
Executable file
19
tests/test_calculator.sh
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#incarca functia din aplicatie
|
||||||
|
|
||||||
|
source ./app/calculator.sh
|
||||||
|
|
||||||
|
echo "Test: add 2 + 3"
|
||||||
|
|
||||||
|
result=$( add 2 3 )
|
||||||
|
|
||||||
|
if [ "$result" -eq 5 ]; then
|
||||||
|
echo "Test PASSED"
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "Test FAILED"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
Reference in New Issue
Block a user