apiVersion: batch/v1
kind: Job
metadata:
  name: rothstocks-tests
  labels:
    app: rothstock
spec:
  template:
    metadata:
      name: rothstocks-tests
    spec:
      containers:
      - name: rothstocks-tests
        image: 127.0.0.1:30400/rothstocks_test:latest
        args: ["bin/rails db:environment:set RAILS_ENV=test && rake db:drop && rake db:create && rake db:migrate && rake db:test:prepare && rake test"]
        env:
        - name: DATABASE_USER
          valueFrom:
            secretKeyRef:
              name: rothstocks-db-user
              key: username
        - name: DATABASE_PASSWORD
          valueFrom:
            secretKeyRef:
              name: rothstocks-db-user-pass
              key: password
        - name: DATABASE_NAME
          valueFrom:
            secretKeyRef:
              name: rothstocks-db-name
              key: name
        - name: RAILS_ENV
          value: test
        - name: SECRET_KEY_BASE
          valueFrom:
            secretKeyRef:
              name: rothstocks-secrets
              key: secret-key-base          
        - name: REDIS_PASS
          valueFrom:
            secretKeyRef:
              name: redis-test
              key: redis-password
        - name: REDIS_HOST
          value: redis-test-master.app-test.svc.cluster.local
        - name: REDIS_PORT
          value: "6379"
      restartPolicy: Never
  backoffLimit: 1

