Skip to content

Commit d4764fd

Browse files
authored
Rename as sha for tests (#112)
1 parent 1cf711e commit d4764fd

2 files changed

Lines changed: 33 additions & 33 deletions

File tree

tests/integration/core.test.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import {
1212
expectBranchHasFile,
1313
expectBranchHasTree,
1414
expectBranchNotHaveFile,
15-
expectParentHasOid,
16-
getOid,
15+
expectParentHasSha,
16+
getSha,
1717
getTempBranch,
1818
octokit,
1919
owner,
@@ -26,7 +26,7 @@ import {
2626

2727
const BASIC_FILE_CHANGES_PATH = "foo.txt";
2828
const BASIC_FILE_BUFFER = Buffer.alloc(1024, "Hello, world!");
29-
const BASIC_FILE_CHANGES_OID = getOid(BASIC_FILE_BUFFER);
29+
const BASIC_FILE_CHANGES_SHA = getSha(BASIC_FILE_BUFFER);
3030
const BASIC_FILE_CONTENTS = BASIC_FILE_BUFFER.toString("base64");
3131
const BASIC_FILE_CHANGES = {
3232
additions: [
@@ -95,13 +95,13 @@ describe("commitFilesFromBase64", () => {
9595
.trim()
9696
.split("\n")
9797
.map((line) => {
98-
const [oid, tree] = line.split(" ");
99-
return { oid, tree };
98+
const [commitSha, treeSha] = line.split(" ");
99+
return { commitSha, treeSha };
100100
});
101101

102-
testTargetCommit = logs[1]?.oid ?? "N/A";
103-
testTargetCommit2 = logs[0]?.oid ?? "N/A";
104-
testTargetTree2 = logs[0]?.tree ?? "N/A";
102+
testTargetCommit = logs[1]?.commitSha ?? "N/A";
103+
testTargetCommit2 = logs[0]?.commitSha ?? "N/A";
104+
testTargetTree2 = logs[0]?.treeSha ?? "N/A";
105105
});
106106

107107
it("can commit files", async () => {
@@ -140,17 +140,17 @@ describe("commitFilesFromBase64", () => {
140140
await expectBranchHasFile({
141141
branch,
142142
filePath: "new-file.txt",
143-
fileOid: getOid(buffers.newFile),
143+
fileSha: getSha(buffers.newFile),
144144
});
145145
await expectBranchHasFile({
146146
branch,
147147
filePath: "README.md",
148-
fileOid: getOid(buffers.updated),
148+
fileSha: getSha(buffers.updated),
149149
});
150150
await expectBranchHasFile({
151151
branch,
152152
filePath: "tests/file.txt",
153-
fileOid: getOid(buffers.nested),
153+
fileSha: getSha(buffers.nested),
154154
});
155155
await expectBranchNotHaveFile({ branch, filePath: "CHANGELOG.md" });
156156
});
@@ -181,7 +181,7 @@ describe("commitFilesFromBase64", () => {
181181
await expectBranchHasFile({
182182
branch,
183183
filePath: `${sizeName}.txt`,
184-
fileOid: getOid(buffer),
184+
fileSha: getSha(buffer),
185185
});
186186
}
187187
});
@@ -204,7 +204,7 @@ describe("commitFilesFromBase64", () => {
204204
await expectBranchHasFile({
205205
branch,
206206
filePath: BASIC_FILE_CHANGES_PATH,
207-
fileOid: BASIC_FILE_CHANGES_OID,
207+
fileSha: BASIC_FILE_CHANGES_SHA,
208208
});
209209
});
210210

@@ -229,7 +229,7 @@ describe("commitFilesFromBase64", () => {
229229
await expectBranchHasFile({
230230
branch,
231231
filePath: BASIC_FILE_CHANGES_PATH,
232-
fileOid: BASIC_FILE_CHANGES_OID,
232+
fileSha: BASIC_FILE_CHANGES_SHA,
233233
});
234234
});
235235

@@ -250,7 +250,7 @@ describe("commitFilesFromBase64", () => {
250250
await expectBranchHasFile({
251251
branch,
252252
filePath: BASIC_FILE_CHANGES_PATH,
253-
fileOid: BASIC_FILE_CHANGES_OID,
253+
fileSha: BASIC_FILE_CHANGES_SHA,
254254
});
255255
});
256256

@@ -281,10 +281,10 @@ describe("commitFilesFromBase64", () => {
281281
await expectBranchHasFile({
282282
branch,
283283
filePath: BASIC_FILE_CHANGES_PATH,
284-
fileOid: BASIC_FILE_CHANGES_OID,
284+
fileSha: BASIC_FILE_CHANGES_SHA,
285285
});
286286

287-
await expectParentHasOid({ branch, oid: testTargetCommit });
287+
await expectParentHasSha({ branch, sha: testTargetCommit });
288288
await expectBranchDoesNotExist(internalTempBranch);
289289
});
290290

@@ -321,10 +321,10 @@ describe("commitFilesFromBase64", () => {
321321
await expectBranchHasFile({
322322
branch,
323323
filePath: BASIC_FILE_CHANGES_PATH,
324-
fileOid: BASIC_FILE_CHANGES_OID,
324+
fileSha: BASIC_FILE_CHANGES_SHA,
325325
});
326326

327-
await expectParentHasOid({ branch, oid: testTargetCommit });
327+
await expectParentHasSha({ branch, sha: testTargetCommit });
328328
await expectBranchDoesNotExist(internalTempBranch);
329329
});
330330

@@ -354,7 +354,7 @@ describe("commitFilesFromBase64", () => {
354354

355355
await expectBranchHasTree({
356356
branch,
357-
treeOid: testTargetTree2,
357+
treeSha: testTargetTree2,
358358
});
359359
});
360360

@@ -383,7 +383,7 @@ describe("commitFilesFromBase64", () => {
383383
await expectBranchHasFile({
384384
branch,
385385
filePath: BASIC_FILE_CHANGES_PATH,
386-
fileOid: BASIC_FILE_CHANGES_OID,
386+
fileSha: BASIC_FILE_CHANGES_SHA,
387387
});
388388
});
389389

@@ -412,7 +412,7 @@ describe("commitFilesFromBase64", () => {
412412
await expectBranchHasFile({
413413
branch,
414414
filePath: BASIC_FILE_CHANGES_PATH,
415-
fileOid: BASIC_FILE_CHANGES_OID,
415+
fileSha: BASIC_FILE_CHANGES_SHA,
416416
});
417417
});
418418
});

tests/integration/utils.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function getTempBranch(name: string) {
3535
/**
3636
* Calculate the SHA using git blob hash format
3737
*/
38-
export function getOid(contents: Buffer): string {
38+
export function getSha(contents: Buffer): string {
3939
const header = Buffer.from(`blob ${contents.length}\0`);
4040
return crypto
4141
.createHash("sha1")
@@ -48,10 +48,10 @@ export function getOid(contents: Buffer): string {
4848

4949
export async function expectBranchHasTree({
5050
branch,
51-
treeOid,
51+
treeSha,
5252
}: {
5353
branch: string;
54-
treeOid: string;
54+
treeSha: string;
5555
}) {
5656
const ref = (
5757
await getRefTreeQuery(octokit, {
@@ -66,17 +66,17 @@ export async function expectBranchHasTree({
6666
throw new Error("Unexpected missing ref");
6767
}
6868

69-
expect(ref.tree.oid).toEqual(treeOid);
69+
expect(ref.tree.oid).toEqual(treeSha);
7070
}
7171

7272
export async function expectBranchHasFile({
7373
branch,
7474
filePath,
75-
fileOid,
75+
fileSha,
7676
}: {
7777
branch: string;
7878
filePath: string;
79-
fileOid: string;
79+
fileSha: string;
8080
}) {
8181
const ref = (
8282
await getRefTreeQuery(octokit, {
@@ -91,7 +91,7 @@ export async function expectBranchHasFile({
9191
throw new Error("Unexpected missing ref");
9292
}
9393

94-
expect(ref.file?.oid).toEqual(fileOid);
94+
expect(ref.file?.oid).toEqual(fileSha);
9595
}
9696

9797
export async function expectBranchNotHaveFile({
@@ -111,12 +111,12 @@ export async function expectBranchNotHaveFile({
111111
).rejects.toThrow("Could not resolve file for path");
112112
}
113113

114-
export async function expectParentHasOid({
114+
export async function expectParentHasSha({
115115
branch,
116-
oid,
116+
sha,
117117
}: {
118118
branch: string;
119-
oid: string;
119+
sha: string;
120120
}) {
121121
const ref = (
122122
await getRefTreeQuery(octokit, {
@@ -131,7 +131,7 @@ export async function expectParentHasOid({
131131
throw new Error("Unexpected result");
132132
}
133133

134-
expect(ref.parents.nodes?.[0]?.oid).toEqual(oid);
134+
expect(ref.parents.nodes?.[0]?.oid).toEqual(sha);
135135
}
136136

137137
export async function expectBranchDoesNotExist(branch: string) {

0 commit comments

Comments
 (0)