MCPcopy
hub / github.com/cli/cli / TestRemoteTrackingRef

Function TestRemoteTrackingRef

git/client_test.go:1143–1232  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1141}
1142
1143func TestRemoteTrackingRef(t *testing.T) {
1144 t.Run("parsing", func(t *testing.T) {
1145 t.Parallel()
1146
1147 tests := []struct {
1148 name string
1149 remoteTrackingRef string
1150 wantRemoteTrackingRef RemoteTrackingRef
1151 wantError error
1152 }{
1153 {
1154 name: "valid remote tracking ref without slash in branch name",
1155 remoteTrackingRef: "refs/remotes/origin/branchName",
1156 wantRemoteTrackingRef: RemoteTrackingRef{
1157 Remote: "origin",
1158 Branch: "branchName",
1159 },
1160 },
1161 {
1162 name: "valid remote tracking ref with slash in branch name",
1163 remoteTrackingRef: "refs/remotes/origin/branch/name",
1164 wantRemoteTrackingRef: RemoteTrackingRef{
1165 Remote: "origin",
1166 Branch: "branch/name",
1167 },
1168 },
1169 // TODO: Uncomment when we support slashes in remote names
1170 // {
1171 // name: "valid remote tracking ref with slash in remote name",
1172 // remoteTrackingRef: "refs/remotes/my/origin/branchName",
1173 // wantRemoteTrackingRef: RemoteTrackingRef{
1174 // Remote: "my/origin",
1175 // Branch: "branchName",
1176 // },
1177 // },
1178 // {
1179 // name: "valid remote tracking ref with slash in remote name and branch name",
1180 // remoteTrackingRef: "refs/remotes/my/origin/branch/name",
1181 // wantRemoteTrackingRef: RemoteTrackingRef{
1182 // Remote: "my/origin",
1183 // Branch: "branch/name",
1184 // },
1185 // },
1186 {
1187 name: "incorrect parts",
1188 remoteTrackingRef: "refs/remotes/origin",
1189 wantRemoteTrackingRef: RemoteTrackingRef{},
1190 wantError: fmt.Errorf("remote tracking branch must have format refs/remotes/<remote>/<branch> but was: refs/remotes/origin"),
1191 },
1192 {
1193 name: "incorrect prefix type",
1194 remoteTrackingRef: "invalid/remotes/origin/branchName",
1195 wantRemoteTrackingRef: RemoteTrackingRef{},
1196 wantError: fmt.Errorf("remote tracking branch must have format refs/remotes/<remote>/<branch> but was: invalid/remotes/origin/branchName"),
1197 },
1198 {
1199 name: "incorrect ref type",
1200 remoteTrackingRef: "refs/invalid/origin/branchName",

Callers

nothing calls this directly

Calls 5

StringMethod · 0.95
ParseRemoteTrackingRefFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected