Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tester to exit 1 if could not build or some tests failed #66

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion panel/handlers/advertiserhandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ var sequentialTests = []func(t *testing.T){
testAddFunds,
testCreateAd,
testHandleEditAd,
testHandleImpressionAdInteraction,
testPublisherPanel,
testWithdrawPublisherBalanceSuccessfulWithdrawal,
}
Expand Down
Binary file removed panel/panel
Binary file not shown.
17 changes: 15 additions & 2 deletions tester.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,28 @@ run_tests_with_coverage() {
echo -e "${BLUE}- Running tests in $dir ${NC}"

# Run the tests and capture the output
result=$(go build $dir 2>&1)
exit_code=$?

result=$(go test -c $dir 2>&1)
exit_code=$?

if [[ $exit_code -ne 0 ]]; then
echo -e "${RED} Could not build ${dir}${NC}"
exit 1
fi

result=$(go test -coverprofile=coverage.out -v $dir 2>&1)

# Print each test function result with color
echo "$result" | while IFS= read -r line; do
while IFS= read -r line; do
if [[ "$line" == *"--- PASS"* ]]; then
echo -e "${GREEN}✓ $line ${NC}" # Green for pass
elif [[ "$line" == *"--- FAIL"* ]]; then
echo -e "${RED}✕ $line ${NC}" # Red for fail
exit 1
fi
done
done <<< "$result"

# Print the coverage
if [ -f coverage.out ]; then
Expand All @@ -69,6 +80,8 @@ run_tests_with_coverage() {
fi
fi
done

exit 0
}

# Execute the function
Expand Down
Loading