#!/bin/bash # Unit test for docker-socket-proxy component # Following TDD: Write test → Execute test → Test fails → Write minimal code to pass test set -e # Load environment settings SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" ENV_FILE="${SCRIPT_DIR}/TSYSDevStack-SupportStack-Demo-Settings" if [ ! -f "$ENV_FILE" ]; then echo "Error: Environment settings file not found at $ENV_FILE" exit 1 fi source "$ENV_FILE" # Test function to validate docker-socket-proxy test_docker_socket_proxy() { echo "Testing docker-socket-proxy availability and functionality..." # Check if the container exists and is running echo "Looking for container: $DOCKER_SOCKET_PROXY_NAME" if docker ps | grep -q "$DOCKER_SOCKET_PROXY_NAME"; then echo "✓ docker-socket-proxy container is running" else echo "✗ docker-socket-proxy container is NOT running" # Check if another container with similar name is running echo "Checking all containers:" docker ps | grep -i docker return 1 fi # Additional tests can be added here to validate the proxy functionality # For example, testing if it can access the Docker socket and respond appropriately echo "✓ Basic docker-socket-proxy test passed" return 0 } # Execute the test if test_docker_socket_proxy; then echo "✓ docker-socket-proxy test PASSED" exit 0 else echo "✗ docker-socket-proxy test FAILED" exit 1 fi