Skip to content

Commit 58cdc79

Browse files
committed
git-notes.test: avoid fetching notes from GitHub
Every invocation used to fetch notes, multiple times, from https://github.com/gitgitgadget/git. This is undesirable, as it is actually totally irrelevant for the tests what is stored in that repository, the tests only want to verify that `git fetch` was invoked. Let's avoid network accesses unless necessary. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 98dd97b commit 58cdc79

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tests/git-notes.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect, jest, test } from "@jest/globals";
22
import { fileURLToPath } from "url";
33
import { isDirectory } from "../lib/fs-util.js";
4-
import { git, revParse } from "../lib/git.js";
4+
import { emptyBlobName, git, revParse } from "../lib/git.js";
55
import { GitNotes } from "../lib/git-notes.js";
66
import { IPatchSeriesMetadata } from "../lib/patch-series-metadata.js";
77
import { testCreateRepo } from "./test-lib.js";
@@ -23,6 +23,14 @@ test("set/get notes", async () => {
2323
expect(await git(["log", "-p", "refs/notes/gitgitgadget"], { workDir: repo.workDir })).toMatch(/\n\+hello$/);
2424

2525
const gitURL = "https://github.com/gitgitgadget/git";
26+
// avoid network calls during tests
27+
const fakeRemote = `${repo.workDir}/.git/fake-remote`;
28+
await git(["init", "--bare", fakeRemote]);
29+
await git([`--git-dir=${fakeRemote}`, "notes", "--ref=gitgitgadget", "add", "-m", "{}", emptyBlobName]);
30+
await git([`--git-dir=${fakeRemote}`, "notes", "--ref=mail-to-commit", "add", "-m", "1", emptyBlobName]);
31+
await git([`--git-dir=${fakeRemote}`, "notes", "--ref=commit-to-mail", "add", "-m", "1", emptyBlobName]);
32+
await git(["config", `url.${fakeRemote}.insteadof`, gitURL], { workDir: repo.workDir });
33+
2634
const pullRequestURL = `${gitURL}/git/pull/1`;
2735
const metadata: IPatchSeriesMetadata = {
2836
baseCommit: "0123456789012345678901234567890123456789",

0 commit comments

Comments
 (0)