MCPcopy Index your code
hub / github.com/coder/coder / TestGitHubBuildBranchURL

Function TestGitHubBuildBranchURL

coderd/externalauth/gitprovider/github_test.go:247–311  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

245}
246
247func TestGitHubBuildBranchURL(t *testing.T) {
248 t.Parallel()
249 gp, err := gitprovider.New("github", "", nil)
250 require.NoError(t, err)
251 require.NotNil(t, gp)
252
253 tests := []struct {
254 name string
255 owner string
256 repo string
257 branch string
258 expected string
259 }{
260 {
261 name: "Simple branch",
262 owner: "coder",
263 repo: "coder",
264 branch: "main",
265 expected: "https://github.com/coder/coder/tree/main",
266 },
267 {
268 name: "Branch with slash",
269 owner: "coder",
270 repo: "coder",
271 branch: "feat/new-thing",
272 expected: "https://github.com/coder/coder/tree/feat/new-thing",
273 },
274 {
275 name: "Empty owner",
276 owner: "",
277 repo: "coder",
278 branch: "main",
279 expected: "",
280 },
281 {
282 name: "Empty repo",
283 owner: "coder",
284 repo: "",
285 branch: "main",
286 expected: "",
287 },
288 {
289 name: "Empty branch",
290 owner: "coder",
291 repo: "coder",
292 branch: "",
293 expected: "",
294 },
295 {
296 name: "Branch with slashes",
297 owner: "my-org",
298 repo: "my-repo",
299 branch: "feat/new-thing",
300 expected: "https://github.com/my-org/my-repo/tree/feat/new-thing",
301 },
302 }
303
304 for _, tt := range tests {

Callers

nothing calls this directly

Calls 4

NewFunction · 0.92
RunMethod · 0.65
BuildBranchURLMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected