(t *testing.T)
| 849 | } |
| 850 | |
| 851 | func TestParseRemoteTrackingRef(t *testing.T) { |
| 852 | tests := []struct { |
| 853 | name string |
| 854 | ref string |
| 855 | want RemoteTrackingRef |
| 856 | }{ |
| 857 | { |
| 858 | name: "branch without slash", |
| 859 | ref: "refs/remotes/origin/branchName", |
| 860 | want: RemoteTrackingRef{Remote: "origin", Branch: "branchName"}, |
| 861 | }, |
| 862 | { |
| 863 | name: "branch with slash", |
| 864 | ref: "refs/remotes/origin/branch/name", |
| 865 | want: RemoteTrackingRef{Remote: "origin", Branch: "branch/name"}, |
| 866 | }, |
| 867 | } |
| 868 | |
| 869 | for _, tt := range tests { |
| 870 | t.Run(tt.name, func(t *testing.T) { |
| 871 | // Given a qualified remote-tracking ref |
| 872 | ref := tt.ref |
| 873 | |
| 874 | // When it is parsed |
| 875 | trackingRef, err := ParseRemoteTrackingRef(ref) |
| 876 | |
| 877 | // Then the remote and complete branch name are returned |
| 878 | require.NoError(t, err) |
| 879 | assert.Equal(t, tt.want, trackingRef) |
| 880 | }) |
| 881 | } |
| 882 | } |
| 883 | |
| 884 | func TestParseRemoteTrackingRefReportsMalformedInput(t *testing.T) { |
| 885 | tests := []struct { |
nothing calls this directly
no test coverage detected