MCPcopy Create free account
hub / github.com/github/gh-aw / TestApplySafeOutputEnvToMap

Function TestApplySafeOutputEnvToMap

pkg/workflow/safe_output_helpers_test.go:210–295  ·  view source on GitHub ↗

TestApplySafeOutputEnvToMap verifies the helper function for map[string]string env variables

(t *testing.T)

Source from the content-addressed store, hash-verified

208
209// TestApplySafeOutputEnvToMap verifies the helper function for map[string]string env variables
210func 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 },

Callers

nothing calls this directly

Calls 4

templatableBoolPtrFunction · 0.85
applySafeOutputEnvToMapFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected