(t *testing.T)
| 28 | } |
| 29 | |
| 30 | func 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 := `--- |
| 57 | name: Example Agentic Workflow |
| 58 | on: |
| 59 | workflow_dispatch: |
| 60 | permissions: |
| 61 | contents: read |
| 62 | actions: read |
| 63 | engine: copilot |
| 64 | strict: true |
| 65 | timeout-minutes: 5 |
| 66 | --- |
| 67 | |
| 68 | Say 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 | } |
nothing calls this directly
no test coverage detected