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

Function TestClientAddRemote

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

Source from the content-addressed store, hash-verified

1904}
1905
1906func TestClientAddRemote(t *testing.T) {
1907 tests := []struct {
1908 title string
1909 name string
1910 url string
1911 branches []string
1912 dir string
1913 cmdExitStatus int
1914 cmdStdout string
1915 cmdStderr string
1916 wantCmdArgs string
1917 wantErrorMsg string
1918 }{
1919 {
1920 title: "fetch all",
1921 name: "test",
1922 url: "URL",
1923 dir: "DIRECTORY",
1924 branches: []string{},
1925 wantCmdArgs: `path/to/git -C DIRECTORY remote add test URL`,
1926 },
1927 {
1928 title: "fetch specific branches only",
1929 name: "test",
1930 url: "URL",
1931 dir: "DIRECTORY",
1932 branches: []string{"trunk", "dev"},
1933 wantCmdArgs: `path/to/git -C DIRECTORY remote add -t trunk -t dev test URL`,
1934 },
1935 }
1936 for _, tt := range tests {
1937 t.Run(tt.title, func(t *testing.T) {
1938 cmd, cmdCtx := createCommandContext(t, tt.cmdExitStatus, tt.cmdStdout, tt.cmdStderr)
1939 client := Client{
1940 GitPath: "path/to/git",
1941 RepoDir: tt.dir,
1942 commandContext: cmdCtx,
1943 }
1944 _, err := client.AddRemote(context.Background(), tt.name, tt.url, tt.branches)
1945 assert.Equal(t, tt.wantCmdArgs, strings.Join(cmd.Args[3:], " "))
1946 assert.NoError(t, err)
1947 })
1948 }
1949}
1950
1951func initRepo(t *testing.T, dir string) {
1952 errBuf := &bytes.Buffer{}

Callers

nothing calls this directly

Calls 5

AddRemoteMethod · 0.95
createCommandContextFunction · 0.85
EqualMethod · 0.80
JoinMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected