TestExtractSafeScriptsFromFrontmatter verifies extraction from frontmatter TestBuildCustomSafeOutputScriptsJSON verifies JSON generation for script env var
(t *testing.T)
| 70 | // TestExtractSafeScriptsFromFrontmatter verifies extraction from frontmatter |
| 71 | // TestBuildCustomSafeOutputScriptsJSON verifies JSON generation for script env var |
| 72 | func TestBuildCustomSafeOutputScriptsJSON(t *testing.T) { |
| 73 | data := &WorkflowData{ |
| 74 | SafeOutputs: &SafeOutputsConfig{ |
| 75 | Scripts: map[string]*SafeScriptConfig{ |
| 76 | "my-handler": { |
| 77 | Description: "Custom handler", |
| 78 | Script: "return async (m) => ({ success: true });", |
| 79 | }, |
| 80 | }, |
| 81 | }, |
| 82 | } |
| 83 | |
| 84 | jsonStr := buildCustomSafeOutputScriptsJSON(data) |
| 85 | require.NotEmpty(t, jsonStr, "Should produce non-empty JSON") |
| 86 | |
| 87 | var mapping map[string]string |
| 88 | err := json.Unmarshal([]byte(jsonStr), &mapping) |
| 89 | require.NoError(t, err, "JSON should be valid") |
| 90 | |
| 91 | filename, exists := mapping["my_handler"] |
| 92 | require.True(t, exists, "Should have my_handler key (normalized with underscore)") |
| 93 | assert.Equal(t, "safe_output_script_my_handler.cjs", filename, "Filename should match expected pattern") |
| 94 | } |
| 95 | |
| 96 | // TestBuildCustomSafeOutputScriptsJSONNormalization verifies name normalization with dashes |
| 97 | func TestBuildCustomSafeOutputScriptsJSONNormalization(t *testing.T) { |
nothing calls this directly
no test coverage detected