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

Function TestGenerateActionYml

pkg/cli/generate_action_metadata_command_test.go:273–337  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

271}
272
273func TestGenerateActionYml(t *testing.T) {
274 tests := []struct {
275 name string
276 metadata *ActionMetadata
277 expectError bool
278 }{
279 {
280 name: "simple action",
281 metadata: &ActionMetadata{
282 Name: "Test Action",
283 Description: "A test action",
284 ActionName: "test",
285 Inputs: []ActionInput{},
286 Outputs: []ActionOutput{},
287 },
288 expectError: false,
289 },
290 {
291 name: "action with inputs and outputs",
292 metadata: &ActionMetadata{
293 Name: "Complex Action",
294 Description: "A complex action",
295 ActionName: "complex",
296 Inputs: []ActionInput{
297 {Name: "input1", Description: "First input", Required: true},
298 },
299 Outputs: []ActionOutput{
300 {Name: "output1", Description: "First output"},
301 },
302 },
303 expectError: false,
304 },
305 }
306
307 for _, tt := range tests {
308 t.Run(tt.name, func(t *testing.T) {
309 tmpDir := t.TempDir()
310 actionDir := filepath.Join(tmpDir, tt.metadata.ActionName)
311 err := os.MkdirAll(actionDir, 0755)
312 require.NoError(t, err, "Failed to create action directory")
313
314 err = generateActionYml(actionDir, tt.metadata)
315
316 if tt.expectError {
317 require.Error(t, err, "Expected an error")
318 } else {
319 require.NoError(t, err, "Should not error")
320
321 // Verify action.yml was created
322 ymlPath := filepath.Join(actionDir, "action.yml")
323 assert.FileExists(t, ymlPath, "action.yml should be created")
324
325 // Verify file has content
326 content, err := os.ReadFile(ymlPath)
327 require.NoError(t, err, "Should be able to read action.yml")
328 assert.NotEmpty(t, content, "action.yml should have content")
329
330 // Verify required fields are present

Callers

nothing calls this directly

Calls 3

generateActionYmlFunction · 0.85
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected