Test caching multiple files
(mocked_opts, minion_opts, fs_root)
| 348 | |
| 349 | |
| 350 | def test_cache_master(mocked_opts, minion_opts, fs_root): |
| 351 | """ |
| 352 | Test caching multiple files |
| 353 | """ |
| 354 | patched_opts = minion_opts.copy() |
| 355 | patched_opts.update(mocked_opts) |
| 356 | |
| 357 | with patch.dict(fileclient.__opts__, patched_opts): |
| 358 | client = fileclient.get_file_client(fileclient.__opts__, pillar=False) |
| 359 | for saltenv in _saltenvs(): |
| 360 | assert client.cache_master(saltenv=saltenv) |
| 361 | for dirpath, _, filenames in os.walk(os.path.join(fs_root, saltenv)): |
| 362 | for fn in filenames: |
| 363 | fileserver_path = os.path.relpath( |
| 364 | os.path.join(dirpath, fn), fs_root |
| 365 | ) |
| 366 | cachedir_path = os.path.join( |
| 367 | fileclient.__opts__["cachedir"], "files", fileserver_path |
| 368 | ) |
| 369 | assert os.path.exists(cachedir_path) |
| 370 | with salt.utils.files.fopen(cachedir_path) as fp_: |
| 371 | content = fp_.read() |
| 372 | log.debug("cache_loc = %s", cachedir_path) |
| 373 | log.debug("content = %s", content) |
| 374 | assert saltenv in content |
| 375 | |
| 376 | |
| 377 | def test_cache_file_with_alternate_cachedir_and_absolute_path( |