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

Function TestAddWorkflowCreatesGitattributes

pkg/cli/add_integration_test.go:585–631  ·  view source on GitHub ↗

TestAddWorkflowCreatesGitattributes tests that .gitattributes is properly configured

(t *testing.T)

Source from the content-addressed store, hash-verified

583
584// TestAddWorkflowCreatesGitattributes tests that .gitattributes is properly configured
585func TestAddWorkflowCreatesGitattributes(t *testing.T) {
586 setup := setupAddIntegrationTest(t)
587 defer setup.cleanup()
588
589 // Create a local workflow file
590 sourceDir := filepath.Join(setup.tempDir, "source-workflows")
591 err := os.MkdirAll(sourceDir, 0755)
592 require.NoError(t, err, "should create source directory")
593
594 localWorkflowPath := filepath.Join(sourceDir, "test.md")
595 localWorkflowContent := `---
596name: Test
597on: workflow_dispatch
598permissions:
599 contents: read
600engine: copilot
601---
602
603# Test
604
605Content.
606`
607 err = os.WriteFile(localWorkflowPath, []byte(localWorkflowContent), 0644)
608 require.NoError(t, err, "should write local workflow file")
609
610 // Add the workflow
611 cmd := exec.Command(setup.binaryPath, "add", localWorkflowPath)
612 cmd.Dir = setup.tempDir
613 output, err := cmd.CombinedOutput()
614 outputStr := string(output)
615
616 t.Logf("Command output:\n%s", outputStr)
617
618 require.NoError(t, err, "add command should succeed: %s", outputStr)
619
620 // Verify .gitattributes was created
621 gitattributesPath := filepath.Join(setup.tempDir, ".gitattributes")
622 _, err = os.Stat(gitattributesPath)
623 require.NoError(t, err, ".gitattributes file should exist")
624
625 // Verify .gitattributes has the lock file pattern
626 gitattributesContent, err := os.ReadFile(gitattributesPath)
627 require.NoError(t, err, "should read .gitattributes")
628 gitattributesStr := string(gitattributesContent)
629
630 assert.Contains(t, gitattributesStr, ".lock.yml", ".gitattributes should contain lock file pattern")
631}
632
633// TestAddWorkflowNoGitattributes tests that --no-gitattributes skips .gitattributes configuration in the add step
634// Note: The compile step may still create .gitattributes, so we check the verbose output instead

Callers

nothing calls this directly

Calls 1

setupAddIntegrationTestFunction · 0.85

Tested by

no test coverage detected