MCPcopy Create free account
hub / github.com/cloudflare/computer / fakeNetworkGit

Function fakeNetworkGit

packages/computer/src/git/network.test.ts:30–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28} from "./network.js";
29
30function fakeNetworkGit(): {
31 git: IsomorphicGitNetworkClient;
32 calls: Record<string, unknown[][]>;
33} {
34 const calls: Record<string, unknown[][]> = {
35 fetch: [],
36 push: [],
37 pull: [],
38 merge: [],
39 addRemote: [],
40 deleteRemote: [],
41 listRemotes: [],
42 };
43 const git: IsomorphicGitNetworkClient = {
44 fetch: vi.fn(async (args) => {
45 calls.fetch.push([args]);
46 return { defaultBranch: "main", fetchHead: "deadbeef" };
47 }),
48 push: vi.fn(async (args) => {
49 calls.push.push([args]);
50 return { ok: true, error: null, refs: {} };
51 }),
52 pull: vi.fn(async (args) => {
53 calls.pull.push([args]);
54 }),
55 merge: vi.fn(async (args) => {
56 calls.merge.push([args]);
57 return { fastForward: true, oid: "f".repeat(40) };
58 }),
59 addRemote: vi.fn(async (args) => {
60 calls.addRemote.push([args]);
61 }),
62 deleteRemote: vi.fn(async (args) => {
63 calls.deleteRemote.push([args]);
64 }),
65 listRemotes: vi.fn(async (args) => {
66 calls.listRemotes.push([args]);
67 return [];
68 }),
69 };
70 return { git, calls };
71}
72
73const fakeFs = {} as object;
74const fakeHttp = {} as object;

Callers 1

network.test.tsFile · 0.85

Calls 1

pushMethod · 0.65

Tested by

no test coverage detected