test: add rabbitMQ integration test (#29)

* added integration test dependencies

* added rabbitMQ use case integration test

* configured rabbitMQ integration test URI

* fix typo, configured integration test pipeline
This commit is contained in:
Mario Candela
2023-03-21 11:20:12 +01:00
committed by GitHub
parent 1c402141bf
commit 8337281f21
6 changed files with 84 additions and 14 deletions

View File

@ -18,7 +18,7 @@ jobs:
with:
go-version: 1.20.0
- name: Dependences
- name: Dependencies
run: go mod download
- name: Vet
@ -33,17 +33,13 @@ jobs:
go test ./... -v -coverprofile coverage.tmp.out -covermode count
go tool cover -func coverage.tmp.out
- name: Integration tests
run: |
INTEGRATION=1 go test ./... -v
- name: Quality Gate - Test coverage shall be above threshold
env:
TESTCOVERAGE_THRESHOLD: 70
run: |
echo "Quality Gate: checking test coverage is above threshold ..."
echo "Threshold : $TESTCOVERAGE_THRESHOLD %"
# Excluded the concrete strategy from the coverage calculation, this will be tested in the integration tests
# Excluded the concrete strategy from the coverage calculation, because tested by integration tests
cat coverage.tmp.out | grep -v "secureShellStrategy.go" | grep -v "hypertextTransferProtocolStrategy.go" | grep -v "transmissionControlProtocolStrategy.go" > coverage.out
totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
echo "Current test coverage : $totalCoverage %"
@ -54,3 +50,26 @@ jobs:
echo "Failed"
exit 1
fi
- name: Start integration test dependencies
run: |
make test.dependencies.start
- name: Wait for RabbitMQ to be ready
run: |
sleep 2
count=0
until docker exec rabbitmq rabbitmqctl list_queues > /dev/null 2>&1; do
count=$((count+1))
if [ $count -gt 10 ]; then
echo "RabbitMQ did not start within the specified time"
exit 1
fi
echo "Waiting for RabbitMQ to start..."
sleep 5
done
- name: Integration tests
run: |
make test.integration.verbose
make test.dependencies.down