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

Function TestGetActionDirectories

pkg/cli/actions_build_command_test.go:60–129  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

58}
59
60func TestGetActionDirectories(t *testing.T) {
61 tests := []struct {
62 name string
63 setup func(string) error
64 expectError bool
65 expectedLen int
66 }{
67 {
68 name: "no actions directory",
69 setup: func(tmpDir string) error {
70 return nil // Don't create actions/
71 },
72 expectError: true,
73 },
74 {
75 name: "empty actions directory",
76 setup: func(tmpDir string) error {
77 return os.MkdirAll(filepath.Join(tmpDir, "actions"), 0755)
78 },
79 expectError: false,
80 expectedLen: 0,
81 },
82 {
83 name: "actions directory with subdirectories",
84 setup: func(tmpDir string) error {
85 actionsDir := filepath.Join(tmpDir, "actions")
86 if err := os.MkdirAll(filepath.Join(actionsDir, "action1"), 0755); err != nil {
87 return err
88 }
89 if err := os.MkdirAll(filepath.Join(actionsDir, "action2"), 0755); err != nil {
90 return err
91 }
92 return nil
93 },
94 expectError: false,
95 expectedLen: 2,
96 },
97 {
98 name: "actions directory with files and subdirectories",
99 setup: func(tmpDir string) error {
100 actionsDir := filepath.Join(tmpDir, "actions")
101 if err := os.MkdirAll(filepath.Join(actionsDir, "action1"), 0755); err != nil {
102 return err
103 }
104 // Create a file - should not be included
105 return os.WriteFile(filepath.Join(actionsDir, "README.md"), []byte("test"), 0644)
106 },
107 expectError: false,
108 expectedLen: 1,
109 },
110 }
111
112 for _, tt := range tests {
113 t.Run(tt.name, func(t *testing.T) {
114 tmpDir := t.TempDir()
115 err := tt.setup(tmpDir)
116 require.NoError(t, err, "Setup should not fail")
117

Callers

nothing calls this directly

Calls 3

getActionDirectoriesFunction · 0.85
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected