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

Function TestExtractHostFromRemoteURL

pkg/cli/git_test.go:347–436  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

345}
346
347func TestExtractHostFromRemoteURL(t *testing.T) {
348 tests := []struct {
349 name string
350 url string
351 expected string
352 }{
353 {
354 name: "HTTPS with embedded username (Windows-style)",
355 url: "https://bryanknox@github.com/owner/repo.git",
356 expected: "github.com",
357 },
358 {
359 name: "HTTPS with embedded username on GHES",
360 url: "https://user@ghes.example.com/org/repo.git",
361 expected: "ghes.example.com",
362 },
363 {
364 name: "HTTP with embedded username",
365 url: "http://user@ghes.example.com/org/repo.git",
366 expected: "ghes.example.com",
367 },
368 {
369 name: "HTTPS with embedded username and password",
370 url: "https://user:pass@github.com/owner/repo.git",
371 expected: "github.com",
372 },
373 {
374 name: "public GitHub HTTPS",
375 url: "https://github.com/owner/repo.git",
376 expected: "github.com",
377 },
378 {
379 name: "public GitHub SSH scp-like",
380 url: "git@github.com:owner/repo.git",
381 expected: "github.com",
382 },
383 {
384 name: "GHES HTTPS",
385 url: "https://ghes.example.com/org/repo.git",
386 expected: "ghes.example.com",
387 },
388 {
389 name: "GHES SSH scp-like",
390 url: "git@ghes.example.com:org/repo.git",
391 expected: "ghes.example.com",
392 },
393 {
394 name: "GHES HTTPS without .git suffix",
395 url: "https://ghes.example.com/org/repo",
396 expected: "ghes.example.com",
397 },
398 {
399 name: "SSH URL format with user",
400 url: "ssh://git@ghes.example.com/org/repo.git",
401 expected: "ghes.example.com",
402 },
403 {
404 name: "SSH URL format without user",

Callers

nothing calls this directly

Calls 2

extractHostFromRemoteURLFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected