(t *testing.T, sockAddr string)
| 303 | } |
| 304 | |
| 305 | func testMountAPI(t *testing.T, sockAddr string) { |
| 306 | // Disable tests under macOS and linux in the CI since they are locking up |
| 307 | if runtime.GOOS == "darwin" || runtime.GOOS == "linux" { |
| 308 | testy.SkipUnreliable(t) |
| 309 | } |
| 310 | if _, mountFn := mountlib.ResolveMountMethod(""); mountFn == nil { |
| 311 | t.Skip("Test requires working mount command") |
| 312 | } |
| 313 | |
| 314 | ctx := context.Background() |
| 315 | oldCacheDir := config.GetCacheDir() |
| 316 | testDir, testFs := initialise(ctx, t) |
| 317 | err := config.SetCacheDir(testDir) |
| 318 | require.NoError(t, err) |
| 319 | defer func() { |
| 320 | _ = config.SetCacheDir(oldCacheDir) |
| 321 | if !t.Failed() { |
| 322 | fstest.Purge(testFs) |
| 323 | _ = os.RemoveAll(testDir) |
| 324 | } |
| 325 | }() |
| 326 | |
| 327 | // Prepare API client |
| 328 | var cli *APIClient |
| 329 | var unixPath string |
| 330 | if sockAddr != "" { |
| 331 | cli = newAPIClient(t, sockAddr, "") |
| 332 | } else { |
| 333 | unixPath = filepath.Join(testDir, "rclone.sock") |
| 334 | cli = newAPIClient(t, "localhost", unixPath) |
| 335 | } |
| 336 | |
| 337 | // Create mounting volume driver and listen for requests |
| 338 | drv, err := docker.NewDriver(ctx, testDir, nil, nil, false, true) |
| 339 | require.NoError(t, err) |
| 340 | require.NotNil(t, drv) |
| 341 | defer drv.Exit() |
| 342 | |
| 343 | srv := docker.NewServer(drv) |
| 344 | go func() { |
| 345 | var errServe error |
| 346 | if unixPath != "" { |
| 347 | errServe = srv.ServeUnix(unixPath, os.Getgid()) |
| 348 | } else { |
| 349 | errServe = srv.ServeTCP(sockAddr, testDir, nil, false) |
| 350 | } |
| 351 | assert.ErrorIs(t, errServe, http.ErrServerClosed) |
| 352 | }() |
| 353 | defer func() { |
| 354 | err := srv.Shutdown(ctx) |
| 355 | assert.NoError(t, err) |
| 356 | fs.Logf(nil, "Server stopped") |
| 357 | time.Sleep(tempDelay) |
| 358 | }() |
| 359 | time.Sleep(tempDelay) // Let server start |
| 360 | |
| 361 | // Run test sequence |
| 362 | path1 := filepath.Join(testDir, "path1") |
no test coverage detected
searching dependent graphs…