(t *testing.T)
| 110 | } |
| 111 | |
| 112 | func TestPreviewRun(t *testing.T) { |
| 113 | skillContent := heredoc.Doc(` |
| 114 | --- |
| 115 | name: my-skill |
| 116 | description: A test skill |
| 117 | --- |
| 118 | # My Skill |
| 119 | |
| 120 | This is the skill content. |
| 121 | `) |
| 122 | encodedContent := base64.StdEncoding.EncodeToString([]byte(skillContent)) |
| 123 | |
| 124 | tests := []struct { |
| 125 | name string |
| 126 | opts *PreviewOptions |
| 127 | tty bool |
| 128 | httpStubs func(*httpmock.Registry) |
| 129 | wantStdout string |
| 130 | wantErr string |
| 131 | }{ |
| 132 | { |
| 133 | name: "preview specific skill", |
| 134 | tty: true, |
| 135 | opts: &PreviewOptions{ |
| 136 | repo: ghrepo.New("github", "awesome-copilot"), |
| 137 | SkillName: "my-skill", |
| 138 | }, |
| 139 | httpStubs: func(reg *httpmock.Registry) { |
| 140 | reg.Register( |
| 141 | httpmock.REST("GET", "repos/github/awesome-copilot/releases/latest"), |
| 142 | httpmock.StringResponse(`{"tag_name": "v1.0.0"}`), |
| 143 | ) |
| 144 | reg.Register( |
| 145 | httpmock.REST("GET", "repos/github/awesome-copilot/git/ref/tags/v1.0.0"), |
| 146 | httpmock.StringResponse(`{"object": {"sha": "abc123", "type": "commit"}}`), |
| 147 | ) |
| 148 | reg.Register( |
| 149 | httpmock.REST("GET", "repos/github/awesome-copilot/git/trees/abc123"), |
| 150 | httpmock.StringResponse(`{ |
| 151 | "sha": "abc123", |
| 152 | "truncated": false, |
| 153 | "tree": [ |
| 154 | {"path": "skills", "type": "tree", "sha": "tree1"}, |
| 155 | {"path": "skills/my-skill", "type": "tree", "sha": "treeSHA"}, |
| 156 | {"path": "skills/my-skill/SKILL.md", "type": "blob", "sha": "blob123"} |
| 157 | ] |
| 158 | }`), |
| 159 | ) |
| 160 | reg.Register( |
| 161 | httpmock.REST("GET", "repos/github/awesome-copilot/git/trees/treeSHA"), |
| 162 | httpmock.StringResponse(`{ |
| 163 | "tree": [ |
| 164 | {"path": "SKILL.md", "type": "blob", "sha": "blob123", "size": 50} |
| 165 | ] |
| 166 | }`), |
| 167 | ) |
| 168 | reg.Register( |
| 169 | httpmock.REST("GET", "repos/github/awesome-copilot/git/blobs/blob123"), |
nothing calls this directly
no test coverage detected