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

Function TestParseRemoteTrackingRef

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

Source from the content-addressed store, hash-verified

849}
850
851func 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
884func TestParseRemoteTrackingRefReportsMalformedInput(t *testing.T) {
885 tests := []struct {

Callers

nothing calls this directly

Calls 3

ParseRemoteTrackingRefFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected