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

Function TestCrushEngineInstallation

pkg/workflow/crush_engine_test.go:150–226  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

148}
149
150func TestCrushEngineInstallation(t *testing.T) {
151 engine := NewCrushEngine()
152
153 t.Run("standard installation", func(t *testing.T) {
154 workflowData := &WorkflowData{
155 Name: "test-workflow",
156 }
157
158 steps := engine.GetInstallationSteps(workflowData)
159 require.NotEmpty(t, steps, "Should generate installation steps")
160
161 // Should have at least: Node.js setup + Install Crush + Verify Crush CLI installation
162 assert.GreaterOrEqual(t, len(steps), 3, "Should have at least 3 installation steps")
163
164 // Find install step and verify --ignore-scripts is NOT present (Crush needs post-install scripts for native binaries)
165 var installStep string
166 for _, step := range steps {
167 content := strings.Join(step, "\n")
168 if strings.Contains(content, "@charmland/crush@") {
169 installStep = content
170 break
171 }
172 }
173 require.NotEmpty(t, installStep, "Should find a step installing @charmland/crush")
174 assert.NotContains(t, installStep, "--ignore-scripts", "Should not use --ignore-scripts for Crush (requires post-install scripts for native binaries)")
175
176 // Find crush --version step to confirm binary download is forced
177 var versionStep string
178 for _, step := range steps {
179 content := strings.Join(step, "\n")
180 if strings.Contains(content, "crush --version") {
181 versionStep = content
182 break
183 }
184 }
185 require.NotEmpty(t, versionStep, "Should find crush --version step to force binary download")
186 assert.Contains(t, versionStep, "Verify Crush CLI installation", "Should have a descriptive step name")
187 })
188
189 t.Run("custom command skips installation", func(t *testing.T) {
190 workflowData := &WorkflowData{
191 Name: "test-workflow",
192 EngineConfig: &EngineConfig{
193 Command: "/custom/crush",
194 },
195 }
196
197 steps := engine.GetInstallationSteps(workflowData)
198 assert.Empty(t, steps, "Should skip installation when custom command is specified")
199 })
200
201 t.Run("with firewall", func(t *testing.T) {
202 workflowData := &WorkflowData{
203 Name: "test-workflow",
204 NetworkPermissions: &NetworkPermissions{
205 Allowed: []string{"defaults"},
206 Firewall: &FirewallConfig{
207 Enabled: true,

Callers

nothing calls this directly

Calls 3

GetInstallationStepsMethod · 0.95
NewCrushEngineFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected