-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue #198: Avoid getting alerts from Code scanning #201
Changes from 3 commits
99beeaf
e040672
8bc34f1
f827c41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
import { | ||
commitOptionsForTests, | ||
createTempEmptyDir, | ||
dummyCommitBodyText, | ||
dummyCommitSubjectText, | ||
newSimpleGitWithCommitterIdentity | ||
} from '../../src/__tests__/helpers' | ||
|
||
import {CommitBody} from '../../src/commit-body' | ||
import {CommitMessage} from '../../src/commit-message' | ||
import {CommitSubjectParser} from '../../src/commit-subject-parser' | ||
import {GitDirNotInitializedError} from '../../src/errors' | ||
import {GitRepo} from '../../src/git-repo' | ||
import {GitRepoDir} from '../../src/git-repo-dir' | ||
|
||
|
@@ -37,4 +44,33 @@ describe('GitRepo', () => { | |
|
||
expect(gitRepo.isInitialized()).toBe(true) | ||
}) | ||
|
||
it('should check if a repo has commits', async () => { | ||
const gitRepoDir = new GitRepoDir(await createTempEmptyDir()) | ||
const git = await newSimpleGitWithCommitterIdentity(gitRepoDir) | ||
const gitRepo = new GitRepo(gitRepoDir, git) | ||
|
||
await gitRepo.init() | ||
|
||
const subject = CommitSubjectParser.parseText(dummyCommitSubjectText()) | ||
const body = new CommitBody(dummyCommitBodyText()) | ||
|
||
const commitMessage = new CommitMessage(subject, body) | ||
|
||
await expect(gitRepo.hasCommits()).resolves.toBe(false) | ||
|
||
await gitRepo.commit(commitMessage, commitOptionsForTests()) | ||
|
||
await expect(gitRepo.hasCommits()).resolves.toBe(true) | ||
}) | ||
|
||
it('should fail when the repo has not been initialized and check if it has commits', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hi @ivanramosnet I did not understand the test intention well. Maybe it's only me but I would rephrase it to:
|
||
const gitRepoDir = new GitRepoDir(await createTempEmptyDir()) | ||
const git = await newSimpleGitWithCommitterIdentity(gitRepoDir) | ||
const gitRepo = new GitRepo(gitRepoDir, git) | ||
|
||
await expect(gitRepo.hasCommits()).rejects.toThrow( | ||
GitDirNotInitializedError | ||
) | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe:
initialize new git repository, check that there are no comments, add a test comment, check for the comment