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

Function TestNormalizeGitHubHostURL

pkg/stringutil/urls_test.go:137–186  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

135}
136
137func TestNormalizeGitHubHostURL(t *testing.T) {
138 tests := []struct {
139 name string
140 input string
141 expected string
142 }{
143 {
144 name: "adds https scheme to plain hostname",
145 input: "myorg.ghe.com",
146 expected: "https://myorg.ghe.com",
147 },
148 {
149 name: "preserves existing https scheme",
150 input: "https://github.com",
151 expected: "https://github.com",
152 },
153 {
154 name: "preserves existing http scheme",
155 input: "http://github.example.com",
156 expected: "http://github.example.com",
157 },
158 {
159 name: "removes single trailing slash",
160 input: "https://github.com/",
161 expected: "https://github.com",
162 },
163 {
164 name: "removes multiple trailing slashes",
165 input: "https://github.com///",
166 expected: "https://github.com",
167 },
168 {
169 name: "adds https and removes trailing slash from plain hostname",
170 input: "myorg.ghe.com/",
171 expected: "https://myorg.ghe.com",
172 },
173 {
174 name: "public GitHub URL unchanged",
175 input: "https://github.com",
176 expected: "https://github.com",
177 },
178 }
179
180 for _, tt := range tests {
181 t.Run(tt.name, func(t *testing.T) {
182 result := NormalizeGitHubHostURL(tt.input)
183 assert.Equal(t, tt.expected, result, "Normalized URL should match expected")
184 })
185 }
186}

Callers

nothing calls this directly

Calls 2

NormalizeGitHubHostURLFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected