version: 2
jobs:
  build:
    docker:
      - image: golang:1.6.2
      - image: postgres:9.4.1
        environment:
          POSTGRES_USER: ubuntu
          POSTGRES_DB: service_test
    steps:
      - checkout:
          path: /go/src/github.com/circleci/cci-demo-go
      - shell:
          working_directory: /go/src/github.com/circleci/cci-demo-go
          name: "Install JUnit & Setup Test Path"
          command: |
            go get github.com/jstemmer/go-junit-report
            mkdir -p /tmp/test-results
      - shell:
          working_directory: /go/src/github.com/circleci/cci-demo-go
          environment:
            DATABASE_URL: "postgres://ubuntu@localhost:5432/service_test?sslmode=disable"
          command: |
            set -eu
            go get -t -d -v ./...
            export DATABASE_URL="postgres://ubuntu@localhost:5432/service_test?sslmode=disable"
            go test -v -race ./... | go-junit-report > /tmp/test-results/unit-tests.xml
      - test_results_store:
          path: /tmp/test-results

version: 2
jobs:
  build:
    docker:
      - image: golang:1.6.2
      - image: postgres:9.4.1
        environment:
          POSTGRES_USER: ubuntu
          POSTGRES_DB: service_test
    working_directory: /go/src/github.com/circleci/cci-demo-go
    steps:
      - checkout
      - run:
          name: "Install JUnit & Setup Test Path"
          command: |
            go get github.com/jstemmer/go-junit-report
            mkdir -p /tmp/test-results
      - run:
          environment:
            DATABASE_URL: "postgres://ubuntu@localhost:5432/service_test?sslmode=disable"
          command: |
            set -eu
            mkdir -p /tmp/test-results
            go get -t -d -v ./...
            go test -v -race ./... | go-junit-report > /tmp/test-results/unit-tests.xml
      - store_test_results:
          path: /tmp/test-results

Move working_directory to the top; make sure test results dir exists.
Move working_directory to the top; make sure test results dir exists.
