# goss.yaml — Container credential smoke test
# Usage: dgoss run --env-file .env your-image:tag
# See: https://blog.zolty.systems/posts/2026-04-05-goss-container-smoke-testing/

# Layer 0: verify MySQL client exists in the image
file:
  /usr/bin/mysql:
    exists: true

# Layer 1: vars are present at all
env:
  MYSQL_HOST:
    exists: true
  MYSQL_USER:
    exists: true
  MYSQL_PASSWORD:
    exists: true
  MYSQL_DATABASE:
    exists: true

# Layer 2: vars are non-empty
# Goss doesn't have a native "not empty" check on env resources, so use commands
command:
  check-host-not-empty:
    exec: '[ -n "$MYSQL_HOST" ]'
    exit-status: 0
  check-user-not-empty:
    exec: '[ -n "$MYSQL_USER" ]'
    exit-status: 0
  check-password-not-empty:
    exec: '[ -n "$MYSQL_PASSWORD" ]'
    exit-status: 0
  check-database-not-empty:
    exec: '[ -n "$MYSQL_DATABASE" ]'
    exit-status: 0

# Layer 3: credentials actually authenticate
command:
  mysql-connectivity:
    exec: "mysql -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PASSWORD -e 'SELECT 1' $MYSQL_DATABASE"
    exit-status: 0
    timeout: 5000
