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

Function TestParseRemoteTrackingRefReportsMalformedInput

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

Source from the content-addressed store, hash-verified

882}
883
884func 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
909func TestRemoteTrackingRefString(t *testing.T) {
910 // Given a remote and branch name

Callers

nothing calls this directly

Calls 3

ParseRemoteTrackingRefFunction · 0.85
EmptyMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected