-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.sh
More file actions
executable file
·81 lines (67 loc) · 2.67 KB
/
Copy pathrun_tests.sh
File metadata and controls
executable file
·81 lines (67 loc) · 2.67 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# Test runner script for Redmine ONE Webhook Plugin
# Usage: ./run_tests.sh [test_file]
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
PLUGIN_NAME="redmine_one_webhook"
echo -e "${GREEN}Running Redmine ONE Webhook Plugin Tests${NC}"
echo "=========================================="
# Check if running in Docker or locally
if [ -f "/.dockerenv" ] || [ -n "$DOCKER_CONTAINER" ]; then
# Running inside Docker container
REDMINE_ROOT="/usr/src/redmine"
cd "$REDMINE_ROOT"
if [ -n "$1" ]; then
# Run specific test file
TEST_FILE="$1"
echo -e "${YELLOW}Running test: $TEST_FILE${NC}"
RAILS_ENV=test ruby -Itest "plugins/$PLUGIN_NAME/test/$TEST_FILE"
else
# Run all plugin tests
echo -e "${YELLOW}Running all tests...${NC}"
RAILS_ENV=test rake redmine:plugins:test NAME=$PLUGIN_NAME
fi
else
# Running locally - use Docker Compose
if [ ! -d "../pms" ]; then
echo -e "${RED}Error: Cannot find pms directory${NC}"
echo "Please ensure docker-compose setup exists"
exit 1
fi
echo -e "${YELLOW}Running tests via Docker Compose...${NC}"
cd ../pms
# Check if test database is configured
TEST_DB_CONFIGURED=$(docker-compose exec -T redmine bash -c "grep -q 'test:' /usr/src/redmine/config/database.yml && echo 'yes' || echo 'no'" 2>/dev/null || echo "no")
if [ "$TEST_DB_CONFIGURED" = "no" ]; then
echo -e "${RED}Error: Test database not configured${NC}"
echo -e "${YELLOW}Please run './setup_test.sh' first${NC}"
exit 1
fi
if [ -n "$1" ]; then
# Run specific test file
echo -e "${BLUE}Running test file: $1${NC}"
# Add mocha to load path (it's not in Gemfile.lock due to --without test)
docker-compose exec -T redmine bash -c "cd /usr/src/redmine && RUBYLIB='/usr/local/bundle/gems/mocha-3.0.1/lib' RAILS_ENV=test ruby -Itest plugins/$PLUGIN_NAME/test/$1"
else
# Run all tests
echo -e "${BLUE}Running all tests...${NC}"
# Add mocha to load path (it's not in Gemfile.lock due to --without test)
docker-compose exec -T redmine bash -c "cd /usr/src/redmine && RUBYLIB='/usr/local/bundle/gems/mocha-3.0.1/lib' RAILS_ENV=test rake redmine:plugins:test NAME=$PLUGIN_NAME"
fi
TEST_EXIT_CODE=$?
if [ $TEST_EXIT_CODE -eq 0 ]; then
echo ""
echo -e "${GREEN}✓ All tests passed!${NC}"
else
echo ""
echo -e "${RED}✗ Some tests failed${NC}"
fi
exit $TEST_EXIT_CODE
fi
echo -e "${GREEN}Tests completed!${NC}"