(t *testing.T)
| 81 | } |
| 82 | |
| 83 | func TestParseSCPArgs(t *testing.T) { |
| 84 | testCases := []parseTestCase{ |
| 85 | {}, // empty test case |
| 86 | { |
| 87 | Args: []string{"-X", "-Y"}, |
| 88 | ParsedArgs: []string{"-X", "-Y"}, |
| 89 | Command: nil, |
| 90 | }, |
| 91 | { |
| 92 | Args: []string{"-X", "-Y", "-o", "someoption=test"}, |
| 93 | ParsedArgs: []string{"-X", "-Y", "-o", "someoption=test"}, |
| 94 | Command: nil, |
| 95 | }, |
| 96 | { |
| 97 | Args: []string{"-X", "-Y", "-o", "someoption=test", "local/file", "remote:file"}, |
| 98 | ParsedArgs: []string{"-X", "-Y", "-o", "someoption=test"}, |
| 99 | Command: []string{"local/file", "remote:file"}, |
| 100 | }, |
| 101 | { |
| 102 | Args: []string{"-X", "-Y", "-o", "someoption=test", "local/file", "remote:file"}, |
| 103 | ParsedArgs: []string{"-X", "-Y", "-o", "someoption=test"}, |
| 104 | Command: []string{"local/file", "remote:file"}, |
| 105 | }, |
| 106 | { |
| 107 | Args: []string{"local/file", "remote:file"}, |
| 108 | ParsedArgs: []string{}, |
| 109 | Command: []string{"local/file", "remote:file"}, |
| 110 | }, |
| 111 | { |
| 112 | Args: []string{"-c"}, |
| 113 | ParsedArgs: nil, |
| 114 | Command: nil, |
| 115 | Error: "flag: -c requires an argument", |
| 116 | }, |
| 117 | } |
| 118 | |
| 119 | for _, tcase := range testCases { |
| 120 | args, command, err := parseSCPArgs(tcase.Args) |
| 121 | |
| 122 | checkParseResult(t, tcase, args, command, err) |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | func checkParseResult(t *testing.T, tcase parseTestCase, gotArgs, gotCmd []string, gotErr error) { |
| 127 | if tcase.Error != "" { |
nothing calls this directly
no test coverage detected