TestSpec_SafeOutputs_SafeOutputsConfigFromKeys validates that SafeOutputsConfigFromKeys builds a minimal SafeOutputsConfig from a list of safe-output key names, as documented in the workflow package README.md. Spec: "SafeOutputsConfigFromKeys — Creates a config from a list of type keys"
(t *testing.T)
| 131 | // in the workflow package README.md. |
| 132 | // Spec: "SafeOutputsConfigFromKeys — Creates a config from a list of type keys" |
| 133 | func TestSpec_SafeOutputs_SafeOutputsConfigFromKeys(t *testing.T) { |
| 134 | tests := []struct { |
| 135 | name string |
| 136 | keys []string |
| 137 | validate func(t *testing.T, cfg *workflow.SafeOutputsConfig) |
| 138 | }{ |
| 139 | { |
| 140 | name: "empty keys returns empty config", |
| 141 | keys: []string{}, |
| 142 | validate: func(t *testing.T, cfg *workflow.SafeOutputsConfig) { |
| 143 | require.NotNil(t, cfg, "SafeOutputsConfigFromKeys must never return nil") |
| 144 | assert.False(t, workflow.HasSafeOutputsEnabled(cfg), "empty key list must produce no enabled outputs") |
| 145 | }, |
| 146 | }, |
| 147 | { |
| 148 | name: "add-comment key enables the add-comment output", |
| 149 | keys: []string{"add-comment"}, |
| 150 | validate: func(t *testing.T, cfg *workflow.SafeOutputsConfig) { |
| 151 | require.NotNil(t, cfg, "config must not be nil") |
| 152 | assert.True(t, workflow.HasSafeOutputsEnabled(cfg), "add-comment key must enable safe outputs") |
| 153 | }, |
| 154 | }, |
| 155 | { |
| 156 | name: "create-issue key enables the create-issue output", |
| 157 | keys: []string{"create-issue"}, |
| 158 | validate: func(t *testing.T, cfg *workflow.SafeOutputsConfig) { |
| 159 | require.NotNil(t, cfg, "config must not be nil") |
| 160 | assert.True(t, workflow.HasSafeOutputsEnabled(cfg), "create-issue key must enable safe outputs") |
| 161 | }, |
| 162 | }, |
| 163 | { |
| 164 | name: "create-pull-request key enables the create-pull-request output", |
| 165 | keys: []string{"create-pull-request"}, |
| 166 | validate: func(t *testing.T, cfg *workflow.SafeOutputsConfig) { |
| 167 | require.NotNil(t, cfg, "config must not be nil") |
| 168 | assert.True(t, workflow.HasSafeOutputsEnabled(cfg), "create-pull-request key must enable safe outputs") |
| 169 | }, |
| 170 | }, |
| 171 | { |
| 172 | name: "multiple keys enable multiple outputs", |
| 173 | keys: []string{"add-comment", "close-issue", "create-pull-request"}, |
| 174 | validate: func(t *testing.T, cfg *workflow.SafeOutputsConfig) { |
| 175 | require.NotNil(t, cfg, "config must not be nil") |
| 176 | assert.True(t, workflow.HasSafeOutputsEnabled(cfg), "multiple keys must enable safe outputs") |
| 177 | }, |
| 178 | }, |
| 179 | } |
| 180 | |
| 181 | for _, tt := range tests { |
| 182 | t.Run(tt.name, func(t *testing.T) { |
| 183 | cfg := workflow.SafeOutputsConfigFromKeys(tt.keys) |
| 184 | tt.validate(t, cfg) |
| 185 | }) |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | // TestSpec_SafeOutputs_HasSafeOutputsEnabled validates the documented behavior of |
| 190 | // HasSafeOutputsEnabled as described in the workflow package README.md. |
nothing calls this directly
no test coverage detected