MCPcopy Create free account
hub / github.com/cli/cli / TestSimplifyURL

Function TestSimplifyURL

pkg/cmd/repo/clone/clone_test.go:512–563  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

510}
511
512func TestSimplifyURL(t *testing.T) {
513 tests := []struct {
514 name string
515 raw string
516 expectedRaw string
517 }{
518 {
519 name: "empty",
520 raw: "",
521 expectedRaw: "",
522 },
523 {
524 name: "no change, no path",
525 raw: "https://github.com",
526 expectedRaw: "https://github.com",
527 },
528 {
529 name: "no change, single part path",
530 raw: "https://github.com/owner",
531 expectedRaw: "https://github.com/owner",
532 },
533 {
534 name: "no change, two-part path",
535 raw: "https://github.com/owner/repo",
536 expectedRaw: "https://github.com/owner/repo",
537 },
538 {
539 name: "no change, three-part path",
540 raw: "https://github.com/owner/repo/pulls",
541 expectedRaw: "https://github.com/owner/repo",
542 },
543 {
544 name: "no change, two-part path, with query, with fragment",
545 raw: "https://github.com/owner/repo?key=value#fragment",
546 expectedRaw: "https://github.com/owner/repo",
547 },
548 {
549 name: "no change, single part path, with query, with fragment",
550 raw: "https://github.com/owner?key=value#fragment",
551 expectedRaw: "https://github.com/owner",
552 },
553 }
554
555 for _, tt := range tests {
556 t.Run(tt.name, func(t *testing.T) {
557 u, err := url.Parse(tt.raw)
558 require.NoError(t, err)
559 result := simplifyURL(u)
560 assert.Equal(t, tt.expectedRaw, result.String())
561 })
562 }
563}

Callers

nothing calls this directly

Calls 4

simplifyURLFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected