forked from Stellabill/stellabill-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-outbox.sh
More file actions
53 lines (40 loc) · 1.48 KB
/
Copy pathtest-outbox.sh
File metadata and controls
53 lines (40 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# Test script for outbox pattern implementation
# This script should be run after Go is properly installed
echo "Running Outbox Pattern Tests..."
# Clean dependencies
echo "Cleaning dependencies..."
go mod tidy
# Run unit tests with coverage
echo "Running unit tests with coverage..."
go test -v -cover ./internal/outbox/...
# Run integration tests (requires database)
echo "Running integration tests..."
go test -v -tags=integration ./internal/outbox/...
# Run all tests with coverage report
echo "Running all tests with coverage report..."
go test -coverprofile=coverage.out ./...
# Generate HTML coverage report
echo "Generating HTML coverage report..."
go tool cover -html=coverage.out -o coverage.html
# Check coverage threshold
echo "Checking coverage threshold..."
COVERAGE=$(go test -cover ./internal/outbox/... | grep "coverage:" | tail -1 | grep -o "[0-9.]*%" | tr -d '%')
THRESHOLD=95
if (( $(echo "$COVERAGE >= $THRESHOLD" | bc -l) )); then
echo "✅ Coverage $COVERAGE% meets threshold of $THRESHOLD%"
else
echo "❌ Coverage $COVERAGE% is below threshold of $THRESHOLD%"
exit 1
fi
# Run benchmarks
echo "Running benchmarks..."
go test -bench=. ./internal/outbox/...
# Run race condition tests
echo "Running race condition tests..."
go test -race ./internal/outbox/...
# Run memory sanitizer tests
echo "Running memory sanitizer tests..."
go test -msan ./internal/outbox/...
echo "All tests completed successfully!"
echo "Coverage report available at: coverage.html"