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

Function TestInitAndUpgradeWithEmptyAWDirectory

pkg/cli/upgrade_integration_test.go:30–82  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28}
29
30func TestInitAndUpgradeWithEmptyAWDirectory(t *testing.T) {
31 setup := setupIntegrationTest(t)
32 defer setup.cleanup()
33
34 initGit := exec.Command("git", "init", "--quiet")
35 initGit.Dir = setup.tempDir
36 require.NoError(t, initGit.Run(), "git init should succeed")
37
38 awDir := filepath.Join(setup.tempDir, ".github", "aw")
39 require.NoError(t, os.MkdirAll(filepath.Join(awDir, "logs"), 0o755), "should create .github/aw/logs")
40 require.NoError(t, os.WriteFile(filepath.Join(awDir, "actions-lock.json"), []byte("{}\n"), 0o644), "should create actions-lock.json")
41
42 initCmd := exec.Command(setup.binaryPath, "init")
43 initCmd.Dir = setup.tempDir
44 initOutput, initErr := initCmd.CombinedOutput()
45 require.NoError(t, initErr, "init command should succeed with empty .github/aw directory, output: %s", string(initOutput))
46 _, err := os.Stat(filepath.Join(awDir, "actions-lock.json"))
47 require.NoError(t, err, "expected actions-lock.json to be preserved after init")
48 _, err = os.Stat(filepath.Join(awDir, "logs"))
49 require.NoError(t, err, "expected .github/aw/logs to be preserved after init")
50
51 skillPath := filepath.Join(setup.tempDir, ".github", "skills", "agentic-workflows", "SKILL.md")
52 _, err = os.Stat(skillPath)
53 require.NoError(t, err, "expected dispatcher skill file to exist after init")
54
55 workflowPath := filepath.Join(setup.tempDir, ".github", "workflows", "example.md")
56 workflowContent := `---
57name: Example Agentic Workflow
58on:
59 workflow_dispatch:
60permissions:
61 contents: read
62 actions: read
63engine: copilot
64strict: true
65timeout-minutes: 5
66---
67
68Say hello.
69`
70 require.NoError(t, os.WriteFile(workflowPath, []byte(workflowContent), 0o644), "should create sample workflow")
71
72 upgradeCmd := exec.Command(setup.binaryPath, "upgrade", "--no-fix", "--skip-extension-upgrade")
73 upgradeCmd.Dir = setup.tempDir
74 upgradeOutput, upgradeErr := upgradeCmd.CombinedOutput()
75 upgradeOutputStr := string(upgradeOutput)
76 require.NoError(t, upgradeErr, "upgrade command should succeed with empty .github/aw directory, output: %s", upgradeOutputStr)
77 assert.Contains(t, upgradeOutputStr, "Upgrade complete", "Should report upgrade complete")
78 _, err = os.Stat(filepath.Join(awDir, "actions-lock.json"))
79 require.NoError(t, err, "expected actions-lock.json to be preserved after upgrade")
80 _, err = os.Stat(filepath.Join(awDir, "logs"))
81 require.NoError(t, err, "expected .github/aw/logs to be preserved after upgrade")
82}

Callers

nothing calls this directly

Calls 2

setupIntegrationTestFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected