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

Function TestFormatStepWithCommandAndEnv

pkg/workflow/engine_helpers_shared_test.go:130–264  ·  view source on GitHub ↗

TestFormatStepWithCommandAndEnv verifies step formatting with command and environment variables

(t *testing.T)

Source from the content-addressed store, hash-verified

128
129// TestFormatStepWithCommandAndEnv verifies step formatting with command and environment variables
130func TestFormatStepWithCommandAndEnv(t *testing.T) {
131 tests := []struct {
132 name string
133 stepLines []string
134 command string
135 env map[string]string
136 expectedContent []string
137 notExpected []string
138 }{
139 {
140 name: "Simple command without env",
141 stepLines: []string{" - name: Test Step"},
142 command: "echo 'hello world'",
143 env: map[string]string{},
144 expectedContent: []string{
145 " run: |",
146 " echo 'hello world'",
147 },
148 notExpected: []string{"env:"},
149 },
150 {
151 name: "Multi-line command without env",
152 stepLines: []string{" - name: Multi-line Step"},
153 command: "set -o pipefail\necho 'line1'\necho 'line2'",
154 env: map[string]string{},
155 expectedContent: []string{
156 " run: |",
157 " set -o pipefail",
158 " echo 'line1'",
159 " echo 'line2'",
160 },
161 },
162 {
163 name: "Command with single env var",
164 stepLines: []string{" - name: Env Step"},
165 command: "npm test",
166 env: map[string]string{
167 "NODE_ENV": "production",
168 },
169 expectedContent: []string{
170 " run: |",
171 " npm test",
172 " env:",
173 " NODE_ENV: production",
174 },
175 },
176 {
177 name: "Command with multiple env vars (sorted)",
178 stepLines: []string{" - name: Complex Step"},
179 command: "make build",
180 env: map[string]string{
181 "ZEBRA": "last",
182 "APPLE": "first",
183 "BETA": "second",
184 "VERSION": "${{ github.sha }}",
185 },
186 expectedContent: []string{
187 " run: |",

Callers

nothing calls this directly

Calls 3

RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected