From 05dea8f44e7d2d3f07e3599a70bc819b5763f789 Mon Sep 17 00:00:00 2001 From: Michael Brooks Date: Fri, 16 Oct 2026 12:04:28 -0600 Subject: [PATCH] refactor: remove unused getProjectDirRelPath function --- internal/runtime/python/python.go | 20 --------- internal/runtime/python/python_test.go | 59 -------------------------- 2 files changed, 79 deletions(-) diff --git a/internal/runtime/python/python.go b/internal/runtime/python/python.go index 1572cb70..1d3e5a22 100644 --- a/internal/runtime/python/python.go +++ b/internal/runtime/python/python.go @@ -447,23 +447,3 @@ func IsRuntimeForProject(ctx context.Context, fs afero.Fs, dirPath string, sdkCo return false } - -// getProjectDirRelPath returns the relative path from current working directory -// to projectDirPath or an error. When an error occurs, the projectDirPath is -// returned as the relative path. -func getProjectDirRelPath(os types.Os, currentDirPath string, projectDirPath string) (string, error) { - // Get the current directory to use as the base for the project - if currentDirPath == "" { - cwd, err := os.Getwd() - if err != nil { - return projectDirPath, err - } - currentDirPath = cwd - } - // Find relative path between current directory and project directory - filePathRel, err := filepath.Rel(currentDirPath, projectDirPath) - if err != nil { - return projectDirPath, err - } - return filePathRel, nil -} diff --git a/internal/runtime/python/python_test.go b/internal/runtime/python/python_test.go index 8d20cf45..6bda436d 100644 --- a/internal/runtime/python/python_test.go +++ b/internal/runtime/python/python_test.go @@ -775,62 +775,3 @@ func Test_Python_IsRuntimeForProject(t *testing.T) { }) } } - -func Test_Python_getProjectDirRelPath(t *testing.T) { - tests := map[string]struct { - currentDirPath string - projectDirPath string - getwdPath string - getwdError error - expectedRelPath string - expectedError error - }{ - "When currentDirPath missing and Getwd returns an error": { - currentDirPath: "", - projectDirPath: "path/to/my-project", - getwdPath: "", - getwdError: fmt.Errorf("Something went wrong"), - expectedRelPath: "path/to/my-project", - expectedError: fmt.Errorf("Something went wrong"), - }, - "When Rel returns an error": { - currentDirPath: "//host/some/remote/volume", - projectDirPath: "path/to/my-project", - getwdPath: "", // Not called - getwdError: nil, // Not called - expectedRelPath: "path/to/my-project", - expectedError: fmt.Errorf("Rel: can't make path/to/my-project relative to //host/some/remote/volume"), - }, - "When current working directory outside the projectDirPath": { - currentDirPath: "path/to", - projectDirPath: "path/to/my-project", - getwdPath: "", // Not called - getwdError: nil, // Not called - expectedRelPath: "my-project", - expectedError: nil, - }, - "When current working directory equals the projectDirPath": { - currentDirPath: "path/to/my-project", - projectDirPath: "path/to/my-project", - getwdPath: "", // Not called - getwdError: nil, // Not called - expectedRelPath: ".", - expectedError: nil, - }, - } - for name, tc := range tests { - t.Run(name, func(t *testing.T) { - // Create mocks - osMock := slackdeps.NewOsMock() - osMock.On("Getwd").Return(tc.getwdPath, tc.getwdError) - osMock.AddDefaultMocks() - - // Run the test - actualRelPath, actualErr := getProjectDirRelPath(osMock, tc.currentDirPath, tc.projectDirPath) - - // Assertions - require.Equal(t, tc.expectedRelPath, actualRelPath) - require.Equal(t, tc.expectedError, actualErr) - }) - } -}