Download __tests__/utils/get-git-path.test.ts from SaylorTwift/openhands: direct link, hf CLI and curl.
- Browser
- Download file 1.79 kB
-
https://huggingface.co/SaylorTwift/openhands/resolve/main/__tests__/utils/get-git-path.test.ts
- Command line
-
hf download hf://SaylorTwift/openhands/__tests__/utils/get-git-path.test.ts
-
curl -L -o get-git-path.test.ts https://huggingface.co/SaylorTwift/openhands/resolve/main/__tests__/utils/get-git-path.test.ts
1.79 kB
| import { describe, it, expect } from "vitest"; | |
| import { DEFAULT_WORKING_DIR } from "#/api/agent-server-config"; | |
| import { getGitPath } from "#/utils/get-git-path"; | |
| describe("getGitPath", () => { | |
| it("should return the default working dir when no repository is selected", () => { | |
| expect(getGitPath(null)).toBe(DEFAULT_WORKING_DIR); | |
| expect(getGitPath(undefined)).toBe(DEFAULT_WORKING_DIR); | |
| }); | |
| it("should handle standard owner/repo format (GitHub)", () => { | |
| expect(getGitPath("OpenHands/OpenHands")).toBe( | |
| `${DEFAULT_WORKING_DIR}/OpenHands`, | |
| ); | |
| expect(getGitPath("facebook/react")).toBe(`${DEFAULT_WORKING_DIR}/react`); | |
| }); | |
| it("should handle nested group paths (GitLab)", () => { | |
| expect(getGitPath("modernhealth/frontend-guild/pan")).toBe( | |
| `${DEFAULT_WORKING_DIR}/pan`, | |
| ); | |
| expect(getGitPath("group/subgroup/repo")).toBe( | |
| `${DEFAULT_WORKING_DIR}/repo`, | |
| ); | |
| expect(getGitPath("a/b/c/d/repo")).toBe(`${DEFAULT_WORKING_DIR}/repo`); | |
| }); | |
| it("should handle single segment paths", () => { | |
| expect(getGitPath("repo")).toBe(`${DEFAULT_WORKING_DIR}/repo`); | |
| }); | |
| it("should handle empty string", () => { | |
| expect(getGitPath("")).toBe(DEFAULT_WORKING_DIR); | |
| }); | |
| describe("with a backend-provided workspace path", () => { | |
| it("prefers the explicit workspace path over derived git paths", () => { | |
| expect( | |
| getGitPath( | |
| "OpenHands/software-agent-sdk", | |
| "/workspace/project/agent-canvas", | |
| ), | |
| ).toBe("/workspace/project/agent-canvas"); | |
| }); | |
| it("ignores blank workspace paths and falls back to heuristics", () => { | |
| expect(getGitPath("OpenHands/software-agent-sdk", " ")).toBe( | |
| `${DEFAULT_WORKING_DIR}/software-agent-sdk`, | |
| ); | |
| }); | |
| }); | |
| }); | |