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