(t *testing.T)
| 882 | } |
| 883 | |
| 884 | func TestParseRemoteTrackingRefReportsMalformedInput(t *testing.T) { |
| 885 | tests := []struct { |
| 886 | name string |
| 887 | ref string |
| 888 | }{ |
| 889 | {name: "missing branch", ref: "refs/remotes/origin"}, |
| 890 | {name: "incorrect refs prefix", ref: "invalid/remotes/origin/branchName"}, |
| 891 | {name: "incorrect ref type", ref: "refs/invalid/origin/branchName"}, |
| 892 | } |
| 893 | |
| 894 | for _, tt := range tests { |
| 895 | t.Run(tt.name, func(t *testing.T) { |
| 896 | // Given a string outside the remote-tracking ref grammar |
| 897 | ref := tt.ref |
| 898 | |
| 899 | // When it is parsed |
| 900 | trackingRef, err := ParseRemoteTrackingRef(ref) |
| 901 | |
| 902 | // Then the invalid value is included in the format diagnostic |
| 903 | require.EqualError(t, err, "remote tracking branch must have format refs/remotes/<remote>/<branch> but was: "+ref) |
| 904 | assert.Empty(t, trackingRef) |
| 905 | }) |
| 906 | } |
| 907 | } |
| 908 | |
| 909 | func TestRemoteTrackingRefString(t *testing.T) { |
| 910 | // Given a remote and branch name |
nothing calls this directly
no test coverage detected