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

Function TestExtractWorkflowDomainConfig

pkg/cli/domains_command_test.go:230–276  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

228}
229
230func TestExtractWorkflowDomainConfig(t *testing.T) {
231 tmpDir := t.TempDir()
232
233 t.Run("workflow with network config", func(t *testing.T) {
234 content := `---
235engine: claude
236network:
237 allowed:
238 - github
239 - python
240 blocked:
241 - bad.example.com
242---
243# Test
244`
245 path := filepath.Join(tmpDir, "test.md")
246 err := os.WriteFile(path, []byte(content), 0600)
247 require.NoError(t, err, "Failed to write test file")
248
249 engineID, network, _, _ := extractWorkflowDomainConfig(path)
250 assert.Equal(t, "claude", engineID, "Engine should be claude")
251 require.NotNil(t, network, "Network should not be nil")
252 assert.Equal(t, []string{"github", "python"}, network.Allowed, "Allowed should match")
253 assert.Equal(t, []string{"bad.example.com"}, network.Blocked, "Blocked should match")
254 })
255
256 t.Run("workflow without network config defaults to copilot", func(t *testing.T) {
257 content := `---
258engine: copilot
259---
260# Test
261`
262 path := filepath.Join(tmpDir, "no-network.md")
263 err := os.WriteFile(path, []byte(content), 0600)
264 require.NoError(t, err, "Failed to write test file")
265
266 engineID, network, _, _ := extractWorkflowDomainConfig(path)
267 assert.Equal(t, "copilot", engineID, "Engine should be copilot")
268 assert.Nil(t, network, "Network should be nil when not configured")
269 })
270
271 t.Run("nonexistent file defaults to copilot", func(t *testing.T) {
272 engineID, network, _, _ := extractWorkflowDomainConfig("/nonexistent/file.md")
273 assert.Equal(t, "copilot", engineID, "Engine should default to copilot")
274 assert.Nil(t, network, "Network should be nil for nonexistent file")
275 })
276}
277
278func TestComputeAllowedDomains(t *testing.T) {
279 t.Run("copilot engine without network config", func(t *testing.T) {

Callers

nothing calls this directly

Calls 2

RunMethod · 0.45

Tested by

no test coverage detected