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

Function Test_parseRemoteURLOrName

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

Source from the content-addressed store, hash-verified

907}
908
909func Test_parseRemoteURLOrName(t *testing.T) {
910 tests := []struct {
911 name string
912 value string
913 wantRemoteURL *url.URL
914 wantRemoteName string
915 }{
916 {
917 name: "empty value",
918 value: "",
919 wantRemoteURL: nil,
920 wantRemoteName: "",
921 },
922 {
923 name: "remote URL",
924 value: "git@github.com:foo/bar.git",
925 wantRemoteURL: &url.URL{
926 Scheme: "ssh",
927 User: url.User("git"),
928 Host: "github.com",
929 Path: "/foo/bar.git",
930 },
931 wantRemoteName: "",
932 },
933 {
934 name: "remote name",
935 value: "origin",
936 wantRemoteURL: nil,
937 wantRemoteName: "origin",
938 },
939 {
940 name: "remote name is from filesystem",
941 value: "./path/to/repo",
942 wantRemoteURL: nil,
943 wantRemoteName: "",
944 },
945 }
946 for _, tt := range tests {
947 t.Run(tt.name, func(t *testing.T) {
948 remoteURL, remoteName := parseRemoteURLOrName(tt.value)
949 assert.Equal(t, tt.wantRemoteURL, remoteURL)
950 assert.Equal(t, tt.wantRemoteName, remoteName)
951 })
952 }
953}
954
955func TestClientPushDefault(t *testing.T) {
956 tests := []struct {

Callers

nothing calls this directly

Calls 3

parseRemoteURLOrNameFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected