(t *testing.T)
| 19 | ) |
| 20 | |
| 21 | func TestNewCmdClone(t *testing.T) { |
| 22 | testCases := []struct { |
| 23 | name string |
| 24 | args string |
| 25 | wantOpts CloneOptions |
| 26 | wantErr string |
| 27 | }{ |
| 28 | { |
| 29 | name: "no arguments", |
| 30 | args: "", |
| 31 | wantErr: "cannot clone: repository argument required", |
| 32 | }, |
| 33 | { |
| 34 | name: "repo argument", |
| 35 | args: "OWNER/REPO", |
| 36 | wantOpts: CloneOptions{ |
| 37 | Repository: "OWNER/REPO", |
| 38 | GitArgs: []string{}, |
| 39 | }, |
| 40 | }, |
| 41 | { |
| 42 | name: "directory argument", |
| 43 | args: "OWNER/REPO mydir", |
| 44 | wantOpts: CloneOptions{ |
| 45 | Repository: "OWNER/REPO", |
| 46 | GitArgs: []string{"mydir"}, |
| 47 | }, |
| 48 | }, |
| 49 | { |
| 50 | name: "git clone arguments", |
| 51 | args: "OWNER/REPO -- --depth 1 --recurse-submodules", |
| 52 | wantOpts: CloneOptions{ |
| 53 | Repository: "OWNER/REPO", |
| 54 | GitArgs: []string{"--depth", "1", "--recurse-submodules"}, |
| 55 | }, |
| 56 | }, |
| 57 | { |
| 58 | name: "no-upstream flag", |
| 59 | args: "OWNER/REPO --no-upstream", |
| 60 | wantOpts: CloneOptions{ |
| 61 | Repository: "OWNER/REPO", |
| 62 | GitArgs: []string{}, |
| 63 | NoUpstream: true, |
| 64 | }, |
| 65 | }, |
| 66 | { |
| 67 | name: "no-upstream with upstream-remote-name", |
| 68 | args: "OWNER/REPO --no-upstream --upstream-remote-name test", |
| 69 | wantErr: "if any flags in the group [upstream-remote-name no-upstream] are set none of the others can be; [no-upstream upstream-remote-name] were all set", |
| 70 | }, |
| 71 | { |
| 72 | name: "unknown argument", |
| 73 | args: "OWNER/REPO --depth 1", |
| 74 | wantErr: "unknown flag: --depth\nSeparate git clone flags with '--'.", |
| 75 | }, |
| 76 | } |
| 77 | for _, tt := range testCases { |
| 78 | t.Run(tt.name, func(t *testing.T) { |
nothing calls this directly
no test coverage detected