(t *testing.T)
| 193 | } |
| 194 | |
| 195 | func TestDetermineTransferDirection(t *testing.T) { |
| 196 | local := func(path string) PathInfo { |
| 197 | return PathInfo{Original: path, Path: path, IsRemote: false} |
| 198 | } |
| 199 | remote := func(id, path string) PathInfo { |
| 200 | return PathInfo{Original: id + ":" + path, InstanceID: id, Path: path, IsRemote: true} |
| 201 | } |
| 202 | |
| 203 | tests := []struct { |
| 204 | name string |
| 205 | sources []PathInfo |
| 206 | dest PathInfo |
| 207 | wantDir string |
| 208 | wantID string |
| 209 | expectError bool |
| 210 | errorContains string |
| 211 | }{ |
| 212 | { |
| 213 | name: "upload: single local to remote", |
| 214 | sources: []PathInfo{local("file.txt")}, |
| 215 | dest: remote("inst1", "/home/user/"), |
| 216 | wantDir: "upload", |
| 217 | wantID: "inst1", |
| 218 | }, |
| 219 | { |
| 220 | name: "upload: multiple local to remote", |
| 221 | sources: []PathInfo{local("a.txt"), local("b.txt")}, |
| 222 | dest: remote("inst1", "/home/user/"), |
| 223 | wantDir: "upload", |
| 224 | wantID: "inst1", |
| 225 | }, |
| 226 | { |
| 227 | name: "download: single remote to local", |
| 228 | sources: []PathInfo{remote("inst1", "/data/file.txt")}, |
| 229 | dest: local("./"), |
| 230 | wantDir: "download", |
| 231 | wantID: "inst1", |
| 232 | }, |
| 233 | { |
| 234 | name: "download: multiple remote same instance", |
| 235 | sources: []PathInfo{remote("inst1", "/a.txt"), remote("inst1", "/b.txt")}, |
| 236 | dest: local("./"), |
| 237 | wantDir: "download", |
| 238 | wantID: "inst1", |
| 239 | }, |
| 240 | { |
| 241 | name: "error: remote to remote", |
| 242 | sources: []PathInfo{remote("inst1", "/a.txt")}, |
| 243 | dest: remote("inst2", "/b/"), |
| 244 | expectError: true, |
| 245 | errorContains: "cannot transfer from remote to remote", |
| 246 | }, |
| 247 | { |
| 248 | name: "error: multiple different instances", |
| 249 | sources: []PathInfo{remote("inst1", "/a.txt"), remote("inst2", "/b.txt")}, |
| 250 | dest: local("./"), |
| 251 | expectError: true, |
| 252 | errorContains: "cannot transfer between multiple instances", |
nothing calls this directly
no test coverage detected