MCPcopy Index your code
hub / github.com/google/go-github / Test_normalizeDocURL

Function Test_normalizeDocURL

tools/metadata/metadata_test.go:32–89  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30}
31
32func Test_normalizeDocURL(t *testing.T) {
33 t.Parallel()
34
35 for _, td := range []struct {
36 name string
37 docURL string
38 want string
39 }{
40 {
41 name: "invalid URL",
42 docURL: "://bad",
43 want: "://bad",
44 },
45 {
46 name: "clean path and add api version",
47 docURL: "https://docs.github.com//rest/repos/repos#get-a-repository",
48 want: "https://docs.github.com/rest/repos/repos?apiVersion=2022-11-28#get-a-repository",
49 },
50 {
51 name: "preserve query and add api version",
52 docURL: "https://docs.github.com/rest/repos/repos?foo=bar",
53 want: "https://docs.github.com/rest/repos/repos?apiVersion=2022-11-28&foo=bar",
54 },
55 {
56 name: "preserve existing api version",
57 docURL: "https://docs.github.com/rest/repos/repos?apiVersion=2021-01-01&foo=bar",
58 want: "https://docs.github.com/rest/repos/repos?apiVersion=2021-01-01&foo=bar",
59 },
60 {
61 name: "preserve non-default api version",
62 docURL: "https://docs.github.com/rest/private-registries/organization-configurations?apiVersion=2026-03-10#list-private-registries-for-an-organization",
63 want: "https://docs.github.com/rest/private-registries/organization-configurations?apiVersion=2026-03-10#list-private-registries-for-an-organization",
64 },
65 {
66 name: "enterprise cloud latest rest is normalized",
67 docURL: "https://docs.github.com/enterprise-cloud@latest/rest/repos/repos#get-a-repository",
68 want: "https://docs.github.com/enterprise-cloud@latest/rest/repos/repos?apiVersion=2022-11-28#get-a-repository",
69 },
70 {
71 name: "non rest docs path unchanged",
72 docURL: "https://gist.github.com/jonmagic/5282384165e0f86ef105",
73 want: "https://gist.github.com/jonmagic/5282384165e0f86ef105",
74 },
75 {
76 name: "non docs host unchanged",
77 docURL: "https://example.com/rest/repos/repos",
78 want: "https://example.com/rest/repos/repos",
79 },
80 } {
81 t.Run(td.name, func(t *testing.T) {
82 t.Parallel()
83 got := normalizeDocURL(td.docURL)
84 if got != td.want {
85 t.Errorf("normalizeDocURL() = %v, want %v", got, td.want)
86 }
87 })
88 }
89}

Callers

nothing calls this directly

Calls 2

normalizeDocURLFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…