diff --git a/tests/unit/package_managers/yarn/test_project.py b/tests/unit/package_managers/yarn/test_project.py index b652f7c15..9e3a1ea7b 100644 --- a/tests/unit/package_managers/yarn/test_project.py +++ b/tests/unit/package_managers/yarn/test_project.py @@ -16,10 +16,7 @@ ) from cachi2.core.rooted_path import PathOutsideRoot, RootedPath -# the supportedArchitectures property is not currently mapped in the YarnRc class, but is kept -# here because it's one of the default properties generated by "yarn init -2" -VALID_YARNRC_FILE = """ -cacheFolder: ./.custom/cache +VALID_YARNRC_FILE = """cacheFolder: ./.custom/cache checksumBehavior: ignore enableGlobalCache: true enableImmutableCache: true @@ -32,28 +29,29 @@ globalFolder: /a/global/folder ignorePath: true installStatePath: /custom/install-state.gz +lockfileFilename: custom.lock nodeLinker: pnp npmRegistryServer: https://registry.alternative.com npmScopes: - foobar: - npmRegistryServer: https://registry.foobar.com + foobar: + npmRegistryServer: https://registry.foobar.com patchFolder: /custom/patches +plugins: +- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs + spec: '@yarnpkg/plugin-typescript' +- path: .yarn/plugins/@yarnpkg/plugin-exec.cjs + spec: '@yarnpkg/plugin-exec' pnpDataPath: /custom/.pnp.data.json pnpMode: loose pnpUnpluggedFolder: /some/unplugged/folder -plugins: - - path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs - spec: "@yarnpkg/plugin-typescript" - - path: .yarn/plugins/@yarnpkg/plugin-exec.cjs - spec: "@yarnpkg/plugin-exec" supportedArchitectures: os: - - "linux" + - linux unsafeHttpWhitelist: - - example.org - - foo.bar -yarnPath: .custom/path/yarn-3.6.1.cjs +- example.org +- foo.bar virtualFolder: /custom/__virtual__ +yarnPath: .custom/path/yarn-3.6.1.cjs """ EMPTY_YML_FILE = "" @@ -86,30 +84,7 @@ def _prepare_yarnrc_file(rooted_tmp_path: RootedPath, data: str) -> YarnRc: def test_parse_yarnrc(rooted_tmp_path: RootedPath) -> None: yarn_rc = _prepare_yarnrc_file(rooted_tmp_path, VALID_YARNRC_FILE) - - assert yarn_rc["cacheFolder"] == "./.custom/cache" - assert yarn_rc["checksumBehavior"] == "ignore" - assert yarn_rc["enableGlobalCache"] is True - assert yarn_rc["enableImmutableCache"] is True - assert yarn_rc["enableImmutableInstalls"] is True - assert yarn_rc["enableMirror"] is False - assert yarn_rc["enableScripts"] is False - assert yarn_rc["enableStrictSsl"] is False - assert yarn_rc["enableTelemetry"] is False - assert yarn_rc["globalFolder"] == "/a/global/folder" - assert yarn_rc["ignorePath"] is True - assert yarn_rc["installStatePath"] == "/custom/install-state.gz" - assert yarn_rc["nodeLinker"] == "pnp" - assert yarn_rc["patchFolder"] == "/custom/patches" - assert yarn_rc["pnpDataPath"] == "/custom/.pnp.data.json" - assert yarn_rc["pnpMode"] == "loose" - assert yarn_rc["pnpUnpluggedFolder"] == "/some/unplugged/folder" - assert yarn_rc["npmRegistryServer"] == "https://registry.alternative.com" - assert yarn_rc.registry_server_for_scope("foobar") == "https://registry.foobar.com" - assert yarn_rc.registry_server_for_scope("barfoo") == "https://registry.alternative.com" - assert yarn_rc["unsafeHttpWhitelist"] == ["example.org", "foo.bar"] - assert yarn_rc["yarnPath"] == ".custom/path/yarn-3.6.1.cjs" - assert yarn_rc["virtualFolder"] == "/custom/__virtual__" + assert yaml.safe_dump(yarn_rc.data) == VALID_YARNRC_FILE def test_parse_empty_yarnrc(rooted_tmp_path: RootedPath) -> None: