MCPcopy
hub / github.com/cli/cli / Test_repoFromURL

Function Test_repoFromURL

internal/ghrepo/repo_test.go:10–116  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func Test_repoFromURL(t *testing.T) {
11 tests := []struct {
12 name string
13 input string
14 result string
15 host string
16 err error
17 }{
18 {
19 name: "github.com URL",
20 input: "https://github.com/monalisa/octo-cat.git",
21 result: "monalisa/octo-cat",
22 host: "github.com",
23 err: nil,
24 },
25 {
26 name: "github.com URL with trailing slash",
27 input: "https://github.com/monalisa/octo-cat/",
28 result: "monalisa/octo-cat",
29 host: "github.com",
30 err: nil,
31 },
32 {
33 name: "www.github.com URL",
34 input: "http://www.GITHUB.com/monalisa/octo-cat.git",
35 result: "monalisa/octo-cat",
36 host: "github.com",
37 err: nil,
38 },
39 {
40 name: "too many path components",
41 input: "https://github.com/monalisa/octo-cat/pulls",
42 result: "",
43 host: "",
44 err: errors.New("invalid path: /monalisa/octo-cat/pulls"),
45 },
46 {
47 name: "non-GitHub hostname",
48 input: "https://example.com/one/two",
49 result: "one/two",
50 host: "example.com",
51 err: nil,
52 },
53 {
54 name: "filesystem path",
55 input: "/path/to/file",
56 result: "",
57 host: "",
58 err: errors.New("no hostname detected"),
59 },
60 {
61 name: "filesystem path with scheme",
62 input: "file:///path/to/file",
63 result: "",
64 host: "",
65 err: errors.New("no hostname detected"),
66 },
67 {

Callers

nothing calls this directly

Calls 7

FromURLFunction · 0.85
RunMethod · 0.65
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
ErrorfMethod · 0.65
RepoHostMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected