aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cli/internal/packagemanager/pnpm_test.go
diff options
context:
space:
mode:
author简律纯 <hsiangnianian@outlook.com>2023-04-28 01:36:55 +0800
committer简律纯 <hsiangnianian@outlook.com>2023-04-28 01:36:55 +0800
commitfc8c5fdce62fb229202659408798a7b6c98f6e8b (patch)
tree7554f80e50de4af6fd255afa7c21bcdd58a7af34 /cli/internal/packagemanager/pnpm_test.go
parentdd84b9d64fb98746a230cd24233ff50a562c39c9 (diff)
downloadHydroRoll-fc8c5fdce62fb229202659408798a7b6c98f6e8b.tar.gz
HydroRoll-fc8c5fdce62fb229202659408798a7b6c98f6e8b.zip
Diffstat (limited to 'cli/internal/packagemanager/pnpm_test.go')
-rw-r--r--cli/internal/packagemanager/pnpm_test.go57
1 files changed, 0 insertions, 57 deletions
diff --git a/cli/internal/packagemanager/pnpm_test.go b/cli/internal/packagemanager/pnpm_test.go
deleted file mode 100644
index c05bc43..0000000
--- a/cli/internal/packagemanager/pnpm_test.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package packagemanager
-
-import (
- "os"
- "testing"
-
- "github.com/vercel/turbo/cli/internal/fs"
- "github.com/vercel/turbo/cli/internal/turbopath"
- "gotest.tools/v3/assert"
-)
-
-func pnpmPatchesSection(t *testing.T, pkgJSON *fs.PackageJSON) map[string]interface{} {
- t.Helper()
- pnpmSection, ok := pkgJSON.RawJSON["pnpm"].(map[string]interface{})
- assert.Assert(t, ok)
- patchesSection, ok := pnpmSection["patchedDependencies"].(map[string]interface{})
- assert.Assert(t, ok)
- return patchesSection
-}
-
-func getPnpmPackageJSON(t *testing.T) *fs.PackageJSON {
- t.Helper()
- rawCwd, err := os.Getwd()
- assert.NilError(t, err)
- cwd, err := fs.CheckedToAbsoluteSystemPath(rawCwd)
- assert.NilError(t, err)
- pkgJSONPath := cwd.Join("fixtures", "pnpm-patches.json")
- pkgJSON, err := fs.ReadPackageJSON(pkgJSONPath)
- assert.NilError(t, err)
- return pkgJSON
-}
-
-func Test_PnpmPrunePatches_KeepsNecessary(t *testing.T) {
- pkgJSON := getPnpmPackageJSON(t)
- initialPatches := pnpmPatchesSection(t, pkgJSON)
-
- assert.DeepEqual(t, initialPatches, map[string]interface{}{"is-odd@3.0.1": "patches/is-odd@3.0.1.patch"})
-
- err := pnpmPrunePatches(pkgJSON, []turbopath.AnchoredUnixPath{turbopath.AnchoredUnixPath("patches/is-odd@3.0.1.patch")})
- assert.NilError(t, err)
-
- newPatches := pnpmPatchesSection(t, pkgJSON)
- assert.DeepEqual(t, newPatches, map[string]interface{}{"is-odd@3.0.1": "patches/is-odd@3.0.1.patch"})
-}
-
-func Test_PnpmPrunePatches_RemovesExtra(t *testing.T) {
- pkgJSON := getPnpmPackageJSON(t)
- initialPatches := pnpmPatchesSection(t, pkgJSON)
-
- assert.DeepEqual(t, initialPatches, map[string]interface{}{"is-odd@3.0.1": "patches/is-odd@3.0.1.patch"})
-
- err := pnpmPrunePatches(pkgJSON, nil)
- assert.NilError(t, err)
-
- newPatches := pnpmPatchesSection(t, pkgJSON)
- assert.DeepEqual(t, newPatches, map[string]interface{}{})
-}