aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cli/internal/cacheitem/restore_directory_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/cacheitem/restore_directory_test.go
parentdd84b9d64fb98746a230cd24233ff50a562c39c9 (diff)
downloadHydroRoll-fc8c5fdce62fb229202659408798a7b6c98f6e8b.tar.gz
HydroRoll-fc8c5fdce62fb229202659408798a7b6c98f6e8b.zip
Diffstat (limited to 'cli/internal/cacheitem/restore_directory_test.go')
-rw-r--r--cli/internal/cacheitem/restore_directory_test.go103
1 files changed, 0 insertions, 103 deletions
diff --git a/cli/internal/cacheitem/restore_directory_test.go b/cli/internal/cacheitem/restore_directory_test.go
deleted file mode 100644
index f75bd47..0000000
--- a/cli/internal/cacheitem/restore_directory_test.go
+++ /dev/null
@@ -1,103 +0,0 @@
-package cacheitem
-
-import (
- "reflect"
- "testing"
-
- "github.com/vercel/turbo/cli/internal/turbopath"
-)
-
-func Test_cachedDirTree_getStartingPoint(t *testing.T) {
- testDir := turbopath.AbsoluteSystemPath("")
- tests := []struct {
- name string
-
- // STATE
- cachedDirTree cachedDirTree
-
- // INPUT
- path turbopath.AnchoredSystemPath
-
- // OUTPUT
- calculatedAnchor turbopath.AbsoluteSystemPath
- pathSegments []turbopath.RelativeSystemPath
- }{
- {
- name: "hello world",
- cachedDirTree: cachedDirTree{
- anchorAtDepth: []turbopath.AbsoluteSystemPath{testDir},
- prefix: []turbopath.RelativeSystemPath{},
- },
- path: turbopath.AnchoredUnixPath("hello/world").ToSystemPath(),
- calculatedAnchor: testDir,
- pathSegments: []turbopath.RelativeSystemPath{"hello", "world"},
- },
- {
- name: "has a cache",
- cachedDirTree: cachedDirTree{
- anchorAtDepth: []turbopath.AbsoluteSystemPath{
- testDir,
- testDir.UntypedJoin("hello"),
- },
- prefix: []turbopath.RelativeSystemPath{"hello"},
- },
- path: turbopath.AnchoredUnixPath("hello/world").ToSystemPath(),
- calculatedAnchor: testDir.UntypedJoin("hello"),
- pathSegments: []turbopath.RelativeSystemPath{"world"},
- },
- {
- name: "ask for yourself",
- cachedDirTree: cachedDirTree{
- anchorAtDepth: []turbopath.AbsoluteSystemPath{
- testDir,
- testDir.UntypedJoin("hello"),
- testDir.UntypedJoin("hello", "world"),
- },
- prefix: []turbopath.RelativeSystemPath{"hello", "world"},
- },
- path: turbopath.AnchoredUnixPath("hello/world").ToSystemPath(),
- calculatedAnchor: testDir.UntypedJoin("hello", "world"),
- pathSegments: []turbopath.RelativeSystemPath{},
- },
- {
- name: "three layer cake",
- cachedDirTree: cachedDirTree{
- anchorAtDepth: []turbopath.AbsoluteSystemPath{
- testDir,
- testDir.UntypedJoin("hello"),
- testDir.UntypedJoin("hello", "world"),
- },
- prefix: []turbopath.RelativeSystemPath{"hello", "world"},
- },
- path: turbopath.AnchoredUnixPath("hello/world/again").ToSystemPath(),
- calculatedAnchor: testDir.UntypedJoin("hello", "world"),
- pathSegments: []turbopath.RelativeSystemPath{"again"},
- },
- {
- name: "outside of cache hierarchy",
- cachedDirTree: cachedDirTree{
- anchorAtDepth: []turbopath.AbsoluteSystemPath{
- testDir,
- testDir.UntypedJoin("hello"),
- testDir.UntypedJoin("hello", "world"),
- },
- prefix: []turbopath.RelativeSystemPath{"hello", "world"},
- },
- path: turbopath.AnchoredUnixPath("somewhere/else").ToSystemPath(),
- calculatedAnchor: testDir,
- pathSegments: []turbopath.RelativeSystemPath{"somewhere", "else"},
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- cr := tt.cachedDirTree
- calculatedAnchor, pathSegments := cr.getStartingPoint(tt.path)
- if !reflect.DeepEqual(calculatedAnchor, tt.calculatedAnchor) {
- t.Errorf("cachedDirTree.getStartingPoint() calculatedAnchor = %v, want %v", calculatedAnchor, tt.calculatedAnchor)
- }
- if !reflect.DeepEqual(pathSegments, tt.pathSegments) {
- t.Errorf("cachedDirTree.getStartingPoint() pathSegments = %v, want %v", pathSegments, tt.pathSegments)
- }
- })
- }
-}