|
|
@@ -1,10 +1,46 @@
|
|
|
import { test, expect } from "bun:test"
|
|
|
import {
|
|
|
+ formatImportFileError,
|
|
|
parseShareUrl,
|
|
|
shouldAttachShareAuthHeaders,
|
|
|
transformShareData,
|
|
|
type ShareData,
|
|
|
} from "../../src/cli/cmd/import"
|
|
|
+import { FSUtil } from "@opencode-ai/core/fs-util"
|
|
|
+import { PlatformError } from "effect"
|
|
|
+
|
|
|
+test("formats import file errors", () => {
|
|
|
+ expect(
|
|
|
+ formatImportFileError(
|
|
|
+ "test.json",
|
|
|
+ new PlatformError.PlatformError(
|
|
|
+ new PlatformError.SystemError({
|
|
|
+ _tag: "NotFound",
|
|
|
+ module: "FileSystem",
|
|
|
+ method: "readFileString",
|
|
|
+ }),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ).toBe("File not found: test.json")
|
|
|
+ expect(
|
|
|
+ formatImportFileError(
|
|
|
+ "test.json",
|
|
|
+ new PlatformError.PlatformError(
|
|
|
+ new PlatformError.SystemError({
|
|
|
+ _tag: "PermissionDenied",
|
|
|
+ module: "FileSystem",
|
|
|
+ method: "readFileString",
|
|
|
+ }),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ).toBe("Failed to read file: Permission denied")
|
|
|
+ expect(
|
|
|
+ formatImportFileError(
|
|
|
+ "test.json",
|
|
|
+ new FSUtil.FileSystemError({ method: "readJson", cause: new SyntaxError("Unexpected token") }),
|
|
|
+ ),
|
|
|
+ ).toBe("Invalid JSON in test.json: Unexpected token")
|
|
|
+})
|
|
|
|
|
|
// parseShareUrl tests
|
|
|
test("parses valid share URLs", () => {
|