(t *testing.T)
| 120 | } |
| 121 | |
| 122 | func TestListRun(t *testing.T) { |
| 123 | tests := []struct { |
| 124 | name string |
| 125 | setup func(t *testing.T, repoDir, homeDir string) |
| 126 | opts func(ios *iostreams.IOStreams, repoDir, homeDir string, spy *telemetry.EventRecorderSpy) *ListOptions |
| 127 | wantStdout string |
| 128 | wantJSON string |
| 129 | wantErr string |
| 130 | verify func(t *testing.T, stdout string, spy *telemetry.EventRecorderSpy) |
| 131 | }{ |
| 132 | { |
| 133 | name: "lists project skill for selected shared agent", |
| 134 | setup: func(t *testing.T, repoDir, homeDir string) { |
| 135 | writeSkill(t, repoDir, ".agents/skills/git-commit", remoteSkillFrontmatter("git-commit", "skills/git-commit", "refs/tags/v1.0.0", "")) |
| 136 | }, |
| 137 | opts: func(ios *iostreams.IOStreams, repoDir, homeDir string, spy *telemetry.EventRecorderSpy) *ListOptions { |
| 138 | return &ListOptions{ |
| 139 | IO: ios, |
| 140 | Telemetry: spy, |
| 141 | GitClient: &git.Client{RepoDir: repoDir}, |
| 142 | Agent: "cursor", |
| 143 | Scope: "project", |
| 144 | } |
| 145 | }, |
| 146 | wantStdout: "git-commit\tcursor\tproject\tmonalisa/skills-repo\n", |
| 147 | verify: func(t *testing.T, stdout string, spy *telemetry.EventRecorderSpy) { |
| 148 | events := spy.Events() |
| 149 | require.Len(t, events, 1) |
| 150 | event := events[0] |
| 151 | assert.Equal(t, "skill_list", event.Type) |
| 152 | assert.Equal(t, "cursor", event.Dimensions["agent_hosts"]) |
| 153 | assert.Equal(t, "project", event.Dimensions["scope"]) |
| 154 | assert.Equal(t, int64(1), event.Measures["skill_count"]) |
| 155 | }, |
| 156 | }, |
| 157 | { |
| 158 | name: "lists user skill as json", |
| 159 | setup: func(t *testing.T, repoDir, homeDir string) { |
| 160 | writeSkill(t, homeDir, ".copilot/skills/code-review", remoteSkillFrontmatter("code-review", "skills/code-review", "refs/tags/v2.0.0", "v2.0.0")) |
| 161 | }, |
| 162 | opts: func(ios *iostreams.IOStreams, repoDir, homeDir string, spy *telemetry.EventRecorderSpy) *ListOptions { |
| 163 | exporter := cmdutil.NewJSONExporter() |
| 164 | exporter.SetFields([]string{"skillName", "agentHosts", "scope", "sourceURL", "version", "pinned", "path"}) |
| 165 | return &ListOptions{ |
| 166 | IO: ios, |
| 167 | Telemetry: spy, |
| 168 | GitClient: &git.Client{RepoDir: repoDir}, |
| 169 | Exporter: exporter, |
| 170 | Agent: "github-copilot", |
| 171 | Scope: "user", |
| 172 | } |
| 173 | }, |
| 174 | wantJSON: fmt.Sprintf(`[ |
| 175 | { |
| 176 | "skillName": "code-review", |
| 177 | "agentHosts": ["github-copilot"], |
| 178 | "scope": "user", |
| 179 | "sourceURL": "https://github.com/monalisa/skills-repo", |
nothing calls this directly
no test coverage detected