(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.CommandRecorderSpy) *ListOptions |
| 127 | wantStdout string |
| 128 | wantJSON string |
| 129 | wantErr string |
| 130 | verify func(t *testing.T, stdout string, spy *telemetry.CommandRecorderSpy) |
| 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.CommandRecorderSpy) *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.CommandRecorderSpy) { |
| 148 | require.Len(t, spy.Events, 1) |
| 149 | event := spy.Events[0] |
| 150 | assert.Equal(t, "skill_list", event.Type) |
| 151 | assert.Equal(t, "cursor", event.Dimensions["agent_hosts"]) |
| 152 | assert.Equal(t, "project", event.Dimensions["scope"]) |
| 153 | assert.Equal(t, int64(1), event.Measures["skill_count"]) |
| 154 | }, |
| 155 | }, |
| 156 | { |
| 157 | name: "lists user skill as json", |
| 158 | setup: func(t *testing.T, repoDir, homeDir string) { |
| 159 | writeSkill(t, homeDir, ".copilot/skills/code-review", remoteSkillFrontmatter("code-review", "skills/code-review", "refs/tags/v2.0.0", "v2.0.0")) |
| 160 | }, |
| 161 | opts: func(ios *iostreams.IOStreams, repoDir, homeDir string, spy *telemetry.CommandRecorderSpy) *ListOptions { |
| 162 | exporter := cmdutil.NewJSONExporter() |
| 163 | exporter.SetFields([]string{"skillName", "agentHosts", "scope", "sourceURL", "version", "pinned", "path"}) |
| 164 | return &ListOptions{ |
| 165 | IO: ios, |
| 166 | Telemetry: spy, |
| 167 | GitClient: &git.Client{RepoDir: repoDir}, |
| 168 | Exporter: exporter, |
| 169 | Agent: "github-copilot", |
| 170 | Scope: "user", |
| 171 | } |
| 172 | }, |
| 173 | wantJSON: fmt.Sprintf(`[ |
| 174 | { |
| 175 | "skillName": "code-review", |
| 176 | "agentHosts": ["github-copilot"], |
| 177 | "scope": "user", |
| 178 | "sourceURL": "https://github.com/monalisa/skills-repo", |
| 179 | "version": "v2.0.0", |
nothing calls this directly
no test coverage detected