TestExtractStopTimeFromLockFile tests the ExtractStopTimeFromLockFile function
(t *testing.T)
| 13 | |
| 14 | // TestExtractStopTimeFromLockFile tests the ExtractStopTimeFromLockFile function |
| 15 | func TestExtractStopTimeFromLockFile(t *testing.T) { |
| 16 | tests := []struct { |
| 17 | name string |
| 18 | lockContent string |
| 19 | expectedTime string |
| 20 | }{ |
| 21 | { |
| 22 | name: "valid stop-time in GH_AW_STOP_TIME format", |
| 23 | lockContent: `name: Test Workflow |
| 24 | on: |
| 25 | workflow_dispatch: |
| 26 | jobs: |
| 27 | stop_time_check: |
| 28 | runs-on: ubuntu-latest |
| 29 | steps: |
| 30 | - uses: actions/github-script@v8 |
| 31 | env: |
| 32 | GH_AW_STOP_TIME: 2025-12-31 23:59:59 |
| 33 | GH_AW_WORKFLOW_NAME: "Test Workflow"`, |
| 34 | expectedTime: "2025-12-31 23:59:59", |
| 35 | }, |
| 36 | { |
| 37 | name: "no stop-time in lock file", |
| 38 | lockContent: `name: Test Workflow |
| 39 | on: |
| 40 | workflow_dispatch: |
| 41 | jobs: |
| 42 | test: |
| 43 | runs-on: ubuntu-latest |
| 44 | steps: |
| 45 | - name: Test step |
| 46 | run: echo "No stop time here"`, |
| 47 | expectedTime: "", |
| 48 | }, |
| 49 | { |
| 50 | name: "GH_AW_STOP_TIME with extra whitespace", |
| 51 | lockContent: `name: Test Workflow |
| 52 | on: |
| 53 | workflow_dispatch: |
| 54 | jobs: |
| 55 | stop_time_check: |
| 56 | runs-on: ubuntu-latest |
| 57 | steps: |
| 58 | - uses: actions/github-script@v8 |
| 59 | env: |
| 60 | GH_AW_STOP_TIME: 2025-06-01 12:00:00 |
| 61 | GH_AW_WORKFLOW_NAME: "Test Workflow"`, |
| 62 | expectedTime: "2025-06-01 12:00:00", |
| 63 | }, |
| 64 | { |
| 65 | name: "GH_AW_STOP_TIME quoted (new format)", |
| 66 | lockContent: `name: Test Workflow |
| 67 | on: |
| 68 | workflow_dispatch: |
| 69 | jobs: |
| 70 | stop_time_check: |
| 71 | runs-on: ubuntu-latest |
| 72 | steps: |
nothing calls this directly
no test coverage detected