MCPcopy Create free account
hub / github.com/cli/cli / TestRunLocalInstall

Function TestRunLocalInstall

pkg/cmd/skills/install/install_test.go:1851–2399  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1849}
1850
1851func TestRunLocalInstall(t *testing.T) {
1852 tests := []struct {
1853 name string
1854 isTTY bool
1855 setup func(t *testing.T, sourceDir, targetDir string)
1856 opts func(ios *iostreams.IOStreams, sourceDir, targetDir string) *InstallOptions
1857 verify func(t *testing.T, targetDir string)
1858 wantErr string
1859 wantStdout string
1860 wantStderr string
1861 }{
1862 {
1863 name: "installs skill with local-path metadata",
1864 isTTY: false,
1865 setup: func(t *testing.T, sourceDir, _ string) {
1866 t.Helper()
1867 writeLocalTestSkill(t, sourceDir, filepath.Join("skills", "git-commit"), heredoc.Doc(`
1868 ---
1869 name: git-commit
1870 description: A local skill
1871 ---
1872 # Git Commit
1873 `))
1874 },
1875 opts: func(ios *iostreams.IOStreams, sourceDir, targetDir string) *InstallOptions {
1876 t.Helper()
1877 return &InstallOptions{
1878 IO: ios,
1879 SkillSource: sourceDir,
1880 localPath: sourceDir,
1881 SkillName: "git-commit",
1882 Force: true,
1883 Agent: "github-copilot",
1884 Scope: "project",
1885 ScopeChanged: true,
1886 Dir: targetDir,
1887 GitClient: &git.Client{RepoDir: t.TempDir()},
1888 }
1889 },
1890 verify: func(t *testing.T, targetDir string) {
1891 t.Helper()
1892 data, err := os.ReadFile(filepath.Join(targetDir, "git-commit", "SKILL.md"))
1893 require.NoError(t, err)
1894 assert.Contains(t, string(data), "local-path")
1895 },
1896 wantStdout: "Installed git-commit",
1897 },
1898 {
1899 name: "single skill directory (SKILL.md at root)",
1900 isTTY: false,
1901 setup: func(t *testing.T, sourceDir, _ string) {
1902 t.Helper()
1903 content := heredoc.Doc(`
1904 ---
1905 name: direct-skill
1906 description: Direct
1907 ---
1908 # Direct

Callers

nothing calls this directly

Calls 15

TestFunction · 0.92
writeLocalTestSkillFunction · 0.85
installRunFunction · 0.85
JoinMethod · 0.80
ContainsMethod · 0.80
WriteFileMethod · 0.80
MkdirAllMethod · 0.80
setupMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
HelperMethod · 0.65

Tested by

no test coverage detected