(t *testing.T)
| 117 | } |
| 118 | |
| 119 | func TestSetFieldInOnTrigger(t *testing.T) { |
| 120 | tests := []struct { |
| 121 | name string |
| 122 | content string |
| 123 | fieldName string |
| 124 | fieldValue string |
| 125 | shouldMatch string |
| 126 | expectError bool |
| 127 | }{ |
| 128 | { |
| 129 | name: "set stop-after in existing on trigger", |
| 130 | content: `--- |
| 131 | on: |
| 132 | issues: |
| 133 | types: [opened] |
| 134 | permissions: |
| 135 | contents: read |
| 136 | --- |
| 137 | |
| 138 | # Test Workflow`, |
| 139 | fieldName: "stop-after", |
| 140 | fieldValue: "+48h", |
| 141 | shouldMatch: "stop-after:", |
| 142 | expectError: false, |
| 143 | }, |
| 144 | { |
| 145 | name: "set stop-after with no on field", |
| 146 | content: `--- |
| 147 | permissions: |
| 148 | contents: read |
| 149 | --- |
| 150 | |
| 151 | # Test Workflow`, |
| 152 | fieldName: "stop-after", |
| 153 | fieldValue: "+72h", |
| 154 | shouldMatch: "stop-after:", |
| 155 | expectError: false, |
| 156 | }, |
| 157 | { |
| 158 | name: "override existing stop-after value", |
| 159 | content: `--- |
| 160 | on: |
| 161 | issues: |
| 162 | types: [opened] |
| 163 | stop-after: "+24h" |
| 164 | permissions: |
| 165 | contents: read |
| 166 | --- |
| 167 | |
| 168 | # Test Workflow`, |
| 169 | fieldName: "stop-after", |
| 170 | fieldValue: "+96h", |
| 171 | shouldMatch: "stop-after:", |
| 172 | expectError: false, |
| 173 | }, |
| 174 | { |
| 175 | name: "on field is a string not a map - error case", |
| 176 | content: `--- |
nothing calls this directly
no test coverage detected