Skip to content

Commit

Permalink
test(engine) : testCommitLines 재정의
Browse files Browse the repository at this point in the history
  • Loading branch information
yoouyeon committed Sep 5, 2024
1 parent fbb514f commit 3051635
Showing 1 changed file with 12 additions and 29 deletions.
41 changes: 12 additions & 29 deletions packages/analysis-engine/src/parser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,14 @@ describe("commit message type", () => {
});

describe("getCommitRaws", () => {
const testAuthorCommitter = [
"John Park",
"mail@gmail.com",
"Sun Sep 4 20:17:59 2022 +0900",
"John Park 2",
"mail2@gmail.com",
"Sun Sep 5 20:17:59 2022 +0900",
const testCommitLines = [
`${COMMIT_SEPARATOR}a${GIT_LOG_SEPARATOR}b${GIT_LOG_SEPARATOR}HEAD${GIT_LOG_SEPARATOR}John Park${GIT_LOG_SEPARATOR}mail@gmail.com${GIT_LOG_SEPARATOR}Sun Sep 4 20:17:59 2022 +0900${GIT_LOG_SEPARATOR}John Park 2${GIT_LOG_SEPARATOR}mail2@gmail.com${GIT_LOG_SEPARATOR}Sun Sep 5 20:17:59 2022 +0900${GIT_LOG_SEPARATOR}commit message`,
`${COMMIT_SEPARATOR}a${GIT_LOG_SEPARATOR}b${GIT_LOG_SEPARATOR}HEAD -> main, origin/main, origin/HEAD${GIT_LOG_SEPARATOR}John Park${GIT_LOG_SEPARATOR}mail@gmail.com${GIT_LOG_SEPARATOR}Sun Sep 4 20:17:59 2022 +0900${GIT_LOG_SEPARATOR}John Park 2${GIT_LOG_SEPARATOR}mail2@gmail.com${GIT_LOG_SEPARATOR}Sun Sep 5 20:17:59 2022 +0900${GIT_LOG_SEPARATOR}commit message`,
`${COMMIT_SEPARATOR}a${GIT_LOG_SEPARATOR}b${GIT_LOG_SEPARATOR}HEAD, tag: v1.0.0${GIT_LOG_SEPARATOR}John Park${GIT_LOG_SEPARATOR}mail@gmail.com${GIT_LOG_SEPARATOR}Sun Sep 4 20:17:59 2022 +0900${GIT_LOG_SEPARATOR}John Park 2${GIT_LOG_SEPARATOR}mail2@gmail.com${GIT_LOG_SEPARATOR}Sun Sep 5 20:17:59 2022 +0900${GIT_LOG_SEPARATOR}commit message`,
`${COMMIT_SEPARATOR}a${GIT_LOG_SEPARATOR}b${GIT_LOG_SEPARATOR}HEAD -> main, origin/main, origin/HEAD, tag: v2.0.0${GIT_LOG_SEPARATOR}John Park${GIT_LOG_SEPARATOR}mail@gmail.com${GIT_LOG_SEPARATOR}Sun Sep 4 20:17:59 2022 +0900${GIT_LOG_SEPARATOR}John Park 2${GIT_LOG_SEPARATOR}mail2@gmail.com${GIT_LOG_SEPARATOR}Sun Sep 5 20:17:59 2022 +0900${GIT_LOG_SEPARATOR}commit message`,
`${COMMIT_SEPARATOR}a${GIT_LOG_SEPARATOR}b${GIT_LOG_SEPARATOR}HEAD, tag: v2.0.0, tag: v1.4${GIT_LOG_SEPARATOR}John Park${GIT_LOG_SEPARATOR}mail@gmail.com${GIT_LOG_SEPARATOR}Sun Sep 4 20:17:59 2022 +0900${GIT_LOG_SEPARATOR}John Park 2${GIT_LOG_SEPARATOR}mail2@gmail.com${GIT_LOG_SEPARATOR}Sun Sep 5 20:17:59 2022 +0900${GIT_LOG_SEPARATOR}commit message`,
];

const testRefs = [
"HEAD",
"HEAD -> main, origin/main, origin/HEAD",
"HEAD, tag: v1.0.0",
"HEAD -> main, origin/main, origin/HEAD, tag: v2.0.0",
"HEAD, tag: v2.0.0, tag: v1.4",
];

const testCommitHash = ["a", "b"];

const testCommitMessage = "commit message";

const testCommitLines = testRefs.map((ref) =>
[...testCommitHash, ref, ...testAuthorCommitter, testCommitMessage].join(GIT_LOG_SEPARATOR)
);

const expectedBranches = [
["HEAD"],
["HEAD", "main", "origin/main", "origin/HEAD"],
Expand Down Expand Up @@ -114,11 +97,11 @@ describe("getCommitRaws", () => {
parents: ["b"],
branches: ["HEAD"],
tags: [],
author: { name: testAuthorCommitter[0], email: testAuthorCommitter[1] },
authorDate: new Date(testAuthorCommitter[2]),
committer: { name: testAuthorCommitter[3], email: testAuthorCommitter[4] },
committerDate: new Date(testAuthorCommitter[5]),
message: testCommitMessage,
author: { name: "John Park", email: "mail@gmail.com" },
authorDate: new Date("Sun Sep 4 20:17:59 2022 +0900"),
committer: { name: "John Park 2", email: "mail2@gmail.com" },
committerDate: new Date("Sun Sep 5 20:17:59 2022 +0900"),
message: "commit message",
differenceStatistic: {
totalInsertionCount: 0,
totalDeletionCount: 0,
Expand All @@ -129,7 +112,7 @@ describe("getCommitRaws", () => {

testCommitLines.forEach((mockLog, index) => {
it(`should parse gitlog to commitRaw(branch, tag)`, () => {
const result = getCommitRaws(COMMIT_SEPARATOR + mockLog);
const result = getCommitRaws(mockLog);
const expectedResult = {
...commonExpectatedResult,
branches: expectedBranches[index],
Expand Down

0 comments on commit 3051635

Please sign in to comment.