MCPcopy Create free account
hub / github.com/github/gh-aw / TestExtractBaseRepo

Function TestExtractBaseRepo

pkg/cli/update_actions_test.go:190–236  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

188}
189
190func TestExtractBaseRepo(t *testing.T) {
191 tests := []struct {
192 name string
193 actionPath string
194 want string
195 }{
196 {
197 name: "action without subfolder",
198 actionPath: "actions/checkout",
199 want: "actions/checkout",
200 },
201 {
202 name: "action with one subfolder",
203 actionPath: "actions/cache/restore",
204 want: "actions/cache",
205 },
206 {
207 name: "action with multiple subfolders",
208 actionPath: "github/codeql-action/upload-sarif",
209 want: "github/codeql-action",
210 },
211 {
212 name: "action with deeply nested subfolders",
213 actionPath: "owner/repo/path/to/action",
214 want: "owner/repo",
215 },
216 {
217 name: "action with only owner",
218 actionPath: "owner",
219 want: "owner",
220 },
221 {
222 name: "empty string",
223 actionPath: "",
224 want: "",
225 },
226 }
227
228 for _, tt := range tests {
229 t.Run(tt.name, func(t *testing.T) {
230 got := gitutil.ExtractBaseRepo(tt.actionPath)
231 if got != tt.want {
232 t.Errorf("gitutil.ExtractBaseRepo(%q) = %q, want %q", tt.actionPath, got, tt.want)
233 }
234 })
235 }
236}
237
238func TestMajorVersionPreference(t *testing.T) {
239 // Test that the version selection logic prefers major-only versions (v8)

Callers

nothing calls this directly

Calls 3

ExtractBaseRepoFunction · 0.92
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected