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

Function TestClientAddRemote

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

Source from the content-addressed store, hash-verified

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