(t *testing.T)
| 667 | } |
| 668 | |
| 669 | func TestParseRemoteURLOrName(t *testing.T) { |
| 670 | tests := []struct { |
| 671 | name string |
| 672 | value string |
| 673 | wantRemoteURL *url.URL |
| 674 | wantRemoteName string |
| 675 | }{ |
| 676 | { |
| 677 | name: "empty value", |
| 678 | value: "", |
| 679 | wantRemoteURL: nil, |
| 680 | wantRemoteName: "", |
| 681 | }, |
| 682 | { |
| 683 | name: "remote URL", |
| 684 | value: "git@github.com:foo/bar.git", |
| 685 | wantRemoteURL: &url.URL{ |
| 686 | Scheme: "ssh", |
| 687 | User: url.User("git"), |
| 688 | Host: "github.com", |
| 689 | Path: "/foo/bar.git", |
| 690 | }, |
| 691 | wantRemoteName: "", |
| 692 | }, |
| 693 | { |
| 694 | name: "remote name", |
| 695 | value: "origin", |
| 696 | wantRemoteURL: nil, |
| 697 | wantRemoteName: "origin", |
| 698 | }, |
| 699 | { |
| 700 | name: "remote name is from filesystem", |
| 701 | value: "./path/to/repo", |
| 702 | wantRemoteURL: nil, |
| 703 | wantRemoteName: "", |
| 704 | }, |
| 705 | } |
| 706 | for _, tt := range tests { |
| 707 | t.Run(tt.name, func(t *testing.T) { |
| 708 | // Given a configured branch remote value |
| 709 | value := tt.value |
| 710 | |
| 711 | // When it is classified |
| 712 | remoteURL, remoteName := parseRemoteURLOrName(value) |
| 713 | |
| 714 | // Then URLs and names are returned through their distinct fields |
| 715 | assert.Equal(t, tt.wantRemoteURL, remoteURL) |
| 716 | assert.Equal(t, tt.wantRemoteName, remoteName) |
| 717 | }) |
| 718 | } |
| 719 | } |
| 720 | |
| 721 | func TestClientPushDefaultReturnsGitDefaultWhenUnset(t *testing.T) { |
| 722 | // Given a repository without push.default |
nothing calls this directly
no test coverage detected