forked from gitgitgadget/gitgitgadget
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lint: update tests for linting issues
Fix space formatting issues. Change a numnber of `expect()` to single liners. Signed-off-by: Chris. Webster <[email protected]>
- Loading branch information
Showing
15 changed files
with
349 additions
and
481 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,14 +167,12 @@ blah http://www.github.com\n\nSigned-off-by: x`; | |
|
||
commit.message = `contains a long URL that cannot be wrapped\n\n ${ | ||
""}[2] https://lore.kernel.org/git/CABPp-BH9tju7WVm=${ | ||
""}[email protected]/\n\n${ | ||
""}Signed-off-by: x}`; | ||
""}[email protected]/\n\nSigned-off-by: x}`; | ||
lintCheck(commit); | ||
|
||
commit.message = `contains a long, whitespace-prefixed error message\n\n${ | ||
""} ld-elf.so.1: /usr/local/lib/perl5/5.32/mach/CORE/libperl.so.5.32:${ | ||
""} Undefined symbol "strerror_l@FBSD_1.6"\n\n${ | ||
""}Signed-off-by: x}`; | ||
""} Undefined symbol "strerror_l@FBSD_1.6"\n\nSigned-off-by: x}`; | ||
lintCheck(commit); | ||
}); | ||
|
||
|
@@ -201,8 +199,7 @@ test("combo lint tests", () => { | |
expect(lintError.message).toMatch(/not signed/); | ||
}); | ||
|
||
commit.message = `x: A 34578901234567890123456789012345678901234567890${ | ||
""}123456789012345678901234567890`; | ||
commit.message = `x: A 34578901234567890123456789012345678901234567890123456789012345678901234567890`; | ||
lintCheck(commit, (lintError) => { | ||
expect(lintError.checkFailed).toBe(true); | ||
expect(lintError.message).toMatch(/too short/); | ||
|
@@ -250,16 +247,16 @@ test("lint options tests", () => { | |
}; | ||
|
||
lintCheck(commit, (lintError) => { | ||
expect(lintError.checkFailed).toBe(true); | ||
expect(lintError.message).toMatch(/is too long/); | ||
expect(lintError.message).toMatch(/should be wrapped/); | ||
expect(lintError.message).toMatch(/76/); | ||
}, {}); | ||
expect(lintError.checkFailed).toBe(true); | ||
expect(lintError.message).toMatch(/is too long/); | ||
expect(lintError.message).toMatch(/should be wrapped/); | ||
expect(lintError.message).toMatch(/76/); | ||
}, {}); | ||
|
||
lintCheck(commit, (lintError) => { | ||
expect(lintError.checkFailed).toBe(true); | ||
expect(lintError.message).toMatch(/is too long/); | ||
expect(lintError.message).toMatch(/should be wrapped/); | ||
expect(lintError.message).toMatch(/66/); | ||
}, {maxColumns: 66}); | ||
expect(lintError.checkFailed).toBe(true); | ||
expect(lintError.message).toMatch(/is too long/); | ||
expect(lintError.message).toMatch(/should be wrapped/); | ||
expect(lintError.message).toMatch(/66/); | ||
}, { maxColumns: 66 }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { expect, jest, test } from "@jest/globals"; | ||
import { fileURLToPath } from 'url'; | ||
import { fileURLToPath } from "url"; | ||
import { git, gitCommandExists } from "../lib/git.js"; | ||
import { GitNotes } from "../lib/git-notes.js"; | ||
import { GitGitGadget, IGitGitGadgetOptions } from "../lib/gitgitgadget.js"; | ||
|
@@ -49,10 +49,8 @@ Test H. Dev (1): | |
base-commit: b4bc10cab67df9962ae52c82af9e1a43fd83d806 | ||
Published-As: https://github.com/gitgitgadget/git/releases/tag/${ | ||
"pr-1/somebody/master-v1".replace(/\//g, "%2F")} | ||
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git ${ | ||
""}pr-1/somebody/master-v1 | ||
Published-As: https://github.com/gitgitgadget/git/releases/tag/${"pr-1/somebody/master-v1".replace(/\//g, "%2F")} | ||
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1/somebody/master-v1 | ||
Pull-Request: https://github.com/gitgitgadget/git/pull/1 | ||
--${" "} | ||
gitgitgadget | ||
|
@@ -200,15 +198,13 @@ test("generate tag/notes from a Pull Request", async () => { | |
const pullRequestURL = "https://github.com/gitgitgadget/git/pull/1"; | ||
const pullRequestTitle = "My first Pull Request!"; | ||
const pullRequestBody = `This Pull Request contains some really important ${ | ||
""}changes that I would love to have included in ${ | ||
""}[git.git](https://github.com/git/git). | ||
""}changes that I would love to have included in [git.git](https://github.com/git/git). | ||
Cc: Some Body <[email protected]> | ||
`; | ||
|
||
await git(["config", "user.name", "GitGitGadget"], repo.options); | ||
await git(["config", "user.email", "[email protected]"], | ||
repo.options); | ||
await git(["config", "user.email", "[email protected]"], repo.options); | ||
|
||
const patches = | ||
await PatchSeries.getFromNotes(notes, pullRequestURL, pullRequestTitle, | ||
|
@@ -235,11 +231,9 @@ to have included in git.git [https://github.com/git/git].`); | |
return "Message-ID"; | ||
} | ||
|
||
const metadata = await patches.generateAndSend(logger, send, undefined, | ||
pullRequestURL); | ||
const metadata = await patches.generateAndSend(logger, send, undefined, pullRequestURL); | ||
|
||
expect(metadata?.coverLetterMessageId) | ||
.toMatch(/pull\.1\.git\.\d+\.gitgitgadget@example\.com/); | ||
expect(metadata?.coverLetterMessageId).toMatch(/pull\.1\.git\.\d+\.gitgitgadget@example\.com/); | ||
expect(mails).toEqual(expectedMails); | ||
|
||
expect(await repo.commit("D")).not.toEqual(""); | ||
|
@@ -252,11 +246,9 @@ to have included in git.git [https://github.com/git/git].`); | |
"somebody:master", headCommit2, | ||
{}, "GitHub User", undefined); | ||
mails.splice(0); | ||
const metadata2 = await patches2.generateAndSend(logger, send, undefined, | ||
pullRequestURL); | ||
const metadata2 = await patches2.generateAndSend(logger, send, undefined, pullRequestURL); | ||
|
||
expect(metadata2?.coverLetterMessageId) | ||
.toMatch(/pull\.1\.v2\.git\.\d+\.gitgitgadget@example\.com/); | ||
expect(metadata2?.coverLetterMessageId).toMatch(/pull\.1\.v2\.git\.\d+\.gitgitgadget@example\.com/); | ||
expect(mails).toHaveLength(5); | ||
if (await gitCommandExists("range-diff", repo.workDir)) { | ||
expect(mails[0]).toMatch(/Range-diff vs v1:\n[^]*\n -: .* 4: /); | ||
|
@@ -267,12 +259,10 @@ to have included in git.git [https://github.com/git/git].`); | |
expect(seriesMeta).not.toBeNull(); | ||
expect(seriesMeta?.coverLetterMessageId).not.toBeUndefined(); | ||
const coverMid: string | undefined = seriesMeta?.coverLetterMessageId; | ||
expect(coverMid) | ||
.toMatch(/pull\.1\.v2\.git\.\d+\.gitgitgadget@example\.com/); | ||
expect(coverMid).toMatch(/pull\.1\.v2\.git\.\d+\.gitgitgadget@example\.com/); | ||
expect(seriesMeta?.referencesMessageIds).not.toBeUndefined(); | ||
const refMid: string | undefined = seriesMeta?.referencesMessageIds?.[0]; | ||
expect(refMid) | ||
.toMatch(/pull\.1\.git\.\d+\.gitgitgadget@example\.com/); | ||
expect(refMid).toMatch(/pull\.1\.git\.\d+\.gitgitgadget@example\.com/); | ||
expect(seriesMeta).toEqual({ | ||
baseCommit, | ||
baseLabel: "gitgitgadget:next", | ||
|
@@ -282,14 +272,11 @@ to have included in git.git [https://github.com/git/git].`); | |
iteration: 2, | ||
latestTag: "pr-1/somebody/master-v2", | ||
pullRequestURL, | ||
referencesMessageIds: [ | ||
refMid, | ||
], | ||
referencesMessageIds: [refMid], | ||
} as IPatchSeriesMetadata); | ||
|
||
// verify that the tag was generated correctly | ||
expect((await git(["cat-file", "tag", "pr-1/somebody/master-v2"], | ||
repo.options)) | ||
expect((await git(["cat-file", "tag", "pr-1/somebody/master-v2"], repo.options)) | ||
.replace(/^[^]*?\n\n/, "")).toEqual(`My first Pull Request! | ||
This Pull Request contains some really important changes that I would love | ||
|
@@ -329,9 +316,7 @@ test("allow/disallow", async () => { | |
const remote = await testCreateRepo(sourceFileName, "-remote"); | ||
|
||
await git(["config", "gitgitgadget.workDir", workDir], { workDir }); | ||
await git(["config", | ||
"gitgitgadget.publishRemote", remote.workDir], | ||
{ workDir }); | ||
await git(["config", "gitgitgadget.publishRemote", remote.workDir], { workDir }); | ||
await git(["config", "gitgitgadget.smtpUser", "test"], { workDir }); | ||
await git(["config", "gitgitgadget.smtpHost", "test"], { workDir }); | ||
await git(["config", "gitgitgadget.smtpPass", "test"], { workDir }); | ||
|
@@ -342,20 +327,14 @@ test("allow/disallow", async () => { | |
const gitGitGadget = await GitGitGadget.get(workDir); | ||
|
||
// pretend that the notes ref had been changed in the meantime | ||
await notes.set("", | ||
{ allowedUsers: ["first-one"] } as IGitGitGadgetOptions, | ||
true); | ||
await notes.set("", { allowedUsers: ["first-one"] } as IGitGitGadgetOptions, true); | ||
|
||
expect(gitGitGadget.isUserAllowed("second-one")).toBeFalsy(); | ||
expect(await gitGitGadget.allowUser("first-one", "second-one")) | ||
.toBeTruthy(); | ||
expect(await gitGitGadget.allowUser("first-one", "second-one")) | ||
.toBeFalsy(); | ||
expect(await gitGitGadget.allowUser("first-one", "second-one")).toBeTruthy(); | ||
expect(await gitGitGadget.allowUser("first-one", "second-one")).toBeFalsy(); | ||
expect(gitGitGadget.isUserAllowed("second-one")).toBeTruthy(); | ||
expect(await gitGitGadget.denyUser("first-one", "second-one")) | ||
.toBeTruthy(); | ||
expect(await gitGitGadget.denyUser("first-one", "second-one")) | ||
.toBeFalsy(); | ||
expect(await gitGitGadget.denyUser("first-one", "second-one")).toBeTruthy(); | ||
expect(await gitGitGadget.denyUser("first-one", "second-one")).toBeFalsy(); | ||
expect(gitGitGadget.isUserAllowed("second-one")).toBeFalsy(); | ||
}); | ||
|
||
|
@@ -379,6 +358,5 @@ test("allow/disallow with env vars", async () => { | |
await notes.set("", { allowedUsers: ["first-one"] } as IGitGitGadgetOptions, true); | ||
|
||
expect(gitGitGadget.isUserAllowed("second-one")).toBeFalsy(); | ||
expect(await gitGitGadget.allowUser("first-one", "second-one")) | ||
.toBeTruthy(); | ||
expect(await gitGitGadget.allowUser("first-one", "second-one")).toBeTruthy(); | ||
}); |
Oops, something went wrong.