name: test-run-go-tests-for-path

on:
  workflow_call:
    inputs:
      name:
        description: 'The name to use that will appear in the output log file artifact'
        required: true
        type: string
      path:
        description: 'The path to the test without the precedeing "./" or following "/..." e.g. go test -v ./$path/...'
        required: true
        type: string
    # We will need to add the capacity for receiving passed secrets once we get to the tests that require API credentials

env:
  VAULT_ACC: 1

jobs:
  go-test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
      - uses: ./.github/actions/set-up-go
        with:
          github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
      - run: go test -v ./${{ inputs.path }}/... 2>&1 | tee ${{ inputs.name }}.txt
      - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
        with:
          name: ${{ inputs.name }}-output
          path: ${{ inputs.name }}.txt
          retention-days: 2
