added tests
Some checks failed
Run Integration Tests / test (push) Failing after 12s

This commit is contained in:
partisan 2024-12-05 00:24:47 +01:00
parent 72d76c85ed
commit c8a5ae02c0
8 changed files with 511 additions and 21 deletions

40
run.sh
View file

@ -4,6 +4,8 @@
SKIP_CONFIG=""
PORT=""
DOMAIN=""
BUILD_MODE=false
BUILD_OUTPUT="qgato"
# Parse arguments
while [ $# -gt 0 ]; do
@ -20,6 +22,10 @@ while [ $# -gt 0 ]; do
SKIP_CONFIG="--skip-config-check"
shift
;;
--build)
BUILD_MODE=true
shift
;;
*)
echo "Unknown argument: $1"
exit 1
@ -27,16 +33,30 @@ while [ $# -gt 0 ]; do
esac
done
# List all Go files in this directory
GO_FILES=$(find . -name '*.go' -print)
# Get the directory of the script
SCRIPT_DIR=$(dirname "$0")
# Construct the command
CMD="go run $GO_FILES $SKIP_CONFIG"
[ -n "$PORT" ] && CMD="$CMD --port $PORT"
[ -n "$DOMAIN" ] && CMD="$CMD --domain $DOMAIN"
# List all Go files in the script directory (excluding test files)
GO_FILES=$(find "$SCRIPT_DIR" -name '*.go' ! -name '*_test.go' -print)
# Informative output
echo "Starting application with command: $CMD"
if $BUILD_MODE; then
# Build mode
echo "Building application..."
go build -o "$SCRIPT_DIR/$BUILD_OUTPUT" $GO_FILES
if [ $? -eq 0 ]; then
echo "Build successful! Output: $SCRIPT_DIR/$BUILD_OUTPUT"
else
echo "Build failed!"
exit 1
fi
else
# Run mode
CMD="go run $GO_FILES $SKIP_CONFIG"
[ -n "$PORT" ] && CMD="$CMD --port $PORT"
[ -n "$DOMAIN" ] && CMD="$CMD --domain $DOMAIN"
# Run the Go program with the constructed command
eval $CMD
echo "Starting application with command: $CMD"
# Run the Go program with the constructed command
eval $CMD
fi