(t *testing.T)
| 115 | } |
| 116 | |
| 117 | func TestValidateWorkflowInputs(t *testing.T) { |
| 118 | tests := []struct { |
| 119 | name string |
| 120 | lockContent string |
| 121 | providedInputs []string |
| 122 | expectError bool |
| 123 | errorContains []string // strings that should be in the error message |
| 124 | errorNotContains []string // strings that should NOT be in the error message |
| 125 | }{ |
| 126 | { |
| 127 | name: "all required inputs provided", |
| 128 | lockContent: `name: "Test Workflow" |
| 129 | on: |
| 130 | workflow_dispatch: |
| 131 | inputs: |
| 132 | issue_url: |
| 133 | description: 'Issue URL' |
| 134 | required: true |
| 135 | type: string |
| 136 | jobs: |
| 137 | test: |
| 138 | runs-on: ubuntu-latest |
| 139 | steps: |
| 140 | - run: echo "test" |
| 141 | `, |
| 142 | providedInputs: []string{"issue_url=https://github.com/owner/repo/issues/123"}, |
| 143 | expectError: false, |
| 144 | }, |
| 145 | { |
| 146 | name: "missing required input", |
| 147 | lockContent: `name: "Test Workflow" |
| 148 | on: |
| 149 | workflow_dispatch: |
| 150 | inputs: |
| 151 | issue_url: |
| 152 | description: 'Issue URL' |
| 153 | required: true |
| 154 | type: string |
| 155 | jobs: |
| 156 | test: |
| 157 | runs-on: ubuntu-latest |
| 158 | steps: |
| 159 | - run: echo "test" |
| 160 | `, |
| 161 | providedInputs: []string{}, |
| 162 | expectError: true, |
| 163 | errorContains: []string{"Missing required input(s)", "issue_url", "gh aw run test-workflow -F issue_url=<value>"}, |
| 164 | }, |
| 165 | { |
| 166 | name: "required input with default value - should not error when missing", |
| 167 | lockContent: `name: "Test Workflow" |
| 168 | on: |
| 169 | workflow_dispatch: |
| 170 | inputs: |
| 171 | release_type: |
| 172 | description: 'Release type' |
| 173 | required: true |
| 174 | default: patch |
nothing calls this directly
no test coverage detected