TestApplySafeOutputEnvToMap verifies the helper function for map[string]string env variables
(t *testing.T)
| 208 | |
| 209 | // TestApplySafeOutputEnvToMap verifies the helper function for map[string]string env variables |
| 210 | func TestApplySafeOutputEnvToMap(t *testing.T) { |
| 211 | tests := []struct { |
| 212 | name string |
| 213 | workflowData *WorkflowData |
| 214 | expected map[string]string |
| 215 | }{ |
| 216 | { |
| 217 | name: "nil SafeOutputs", |
| 218 | workflowData: &WorkflowData{ |
| 219 | SafeOutputs: nil, |
| 220 | }, |
| 221 | expected: map[string]string{}, |
| 222 | }, |
| 223 | { |
| 224 | name: "basic safe outputs", |
| 225 | workflowData: &WorkflowData{ |
| 226 | SafeOutputs: &SafeOutputsConfig{}, |
| 227 | }, |
| 228 | expected: map[string]string{ |
| 229 | "GH_AW_SAFE_OUTPUTS": "${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}", |
| 230 | }, |
| 231 | }, |
| 232 | { |
| 233 | name: "safe outputs with staged flag", |
| 234 | workflowData: &WorkflowData{ |
| 235 | SafeOutputs: &SafeOutputsConfig{ |
| 236 | Staged: templatableBoolPtr("true"), |
| 237 | }, |
| 238 | }, |
| 239 | expected: map[string]string{ |
| 240 | "GH_AW_SAFE_OUTPUTS": "${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}", |
| 241 | "GH_AW_SAFE_OUTPUTS_STAGED": "true", |
| 242 | }, |
| 243 | }, |
| 244 | { |
| 245 | name: "trial mode", |
| 246 | workflowData: &WorkflowData{ |
| 247 | TrialMode: true, |
| 248 | TrialLogicalRepo: "owner/repo", |
| 249 | SafeOutputs: &SafeOutputsConfig{}, |
| 250 | }, |
| 251 | expected: map[string]string{ |
| 252 | "GH_AW_SAFE_OUTPUTS": "${{ steps.set-runtime-paths.outputs.GH_AW_SAFE_OUTPUTS }}", |
| 253 | "GH_AW_SAFE_OUTPUTS_STAGED": "true", |
| 254 | "GH_AW_TARGET_REPO_SLUG": "owner/repo", |
| 255 | }, |
| 256 | }, |
| 257 | { |
| 258 | name: "upload assets config", |
| 259 | workflowData: &WorkflowData{ |
| 260 | SafeOutputs: &SafeOutputsConfig{ |
| 261 | UploadAssets: &UploadAssetsConfig{ |
| 262 | BranchName: "gh-aw-assets", |
| 263 | MaxSizeKB: 10240, |
| 264 | AllowedExts: []string{".png", ".jpg", ".jpeg"}, |
| 265 | }, |
| 266 | }, |
| 267 | }, |
nothing calls this directly
no test coverage detected