Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
whywaita committed Oct 17, 2023
1 parent 0748517 commit 80a5cc1
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 28 deletions.
28 changes: 21 additions & 7 deletions __tests__/restore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ test("restore with no cache found", async () => {
{
lookupOnly: false
},
false
false,
undefined,
"",
);

expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
Expand Down Expand Up @@ -124,7 +126,9 @@ test("restore with restore keys and no cache found", async () => {
{
lookupOnly: false
},
false
false,
undefined,
"",
);

expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
Expand Down Expand Up @@ -166,7 +170,9 @@ test("restore with cache found for key", async () => {
{
lookupOnly: false
},
false
false,
undefined,
"",
);

expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
Expand Down Expand Up @@ -211,7 +217,9 @@ test("restore with cache found for restore key", async () => {
{
lookupOnly: false
},
false
false,
undefined,
"",
);

expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
Expand Down Expand Up @@ -256,7 +264,9 @@ test("Fail restore when fail on cache miss is enabled and primary + restore keys
{
lookupOnly: false
},
false
false,
undefined,
"",
);

expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
Expand Down Expand Up @@ -299,7 +309,9 @@ test("restore when fail on cache miss is enabled and primary key doesn't match r
{
lookupOnly: false
},
false
false,
undefined,
"",
);

expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
Expand Down Expand Up @@ -345,7 +357,9 @@ test("restore with fail on cache miss disabled and no cache found", async () =>
{
lookupOnly: false
},
false
false,
undefined,
"",
);

expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
Expand Down
36 changes: 27 additions & 9 deletions __tests__/restoreImpl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ test("restore on GHES with AC available ", async () => {
{
lookupOnly: false
},
false
false,
undefined,
"",
);

expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
Expand Down Expand Up @@ -183,7 +185,9 @@ test("restore with too many keys should fail", async () => {
{
lookupOnly: false
},
false
false,
undefined,
"",
);
expect(failedMock).toHaveBeenCalledWith(
`Key Validation Error: Keys are limited to a maximum of 10.`
Expand All @@ -209,7 +213,9 @@ test("restore with large key should fail", async () => {
{
lookupOnly: false
},
false
false,
undefined,
"",
);
expect(failedMock).toHaveBeenCalledWith(
`Key Validation Error: ${key} cannot be larger than 512 characters.`
Expand All @@ -235,7 +241,9 @@ test("restore with invalid key should fail", async () => {
{
lookupOnly: false
},
false
false,
undefined,
"",
);
expect(failedMock).toHaveBeenCalledWith(
`Key Validation Error: ${key} cannot contain commas.`
Expand Down Expand Up @@ -270,7 +278,9 @@ test("restore with no cache found", async () => {
{
lookupOnly: false
},
false
false,
undefined,
"",
);

expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
Expand Down Expand Up @@ -311,7 +321,9 @@ test("restore with restore keys and no cache found", async () => {
{
lookupOnly: false
},
false
false,
undefined,
"",
);

expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
Expand Down Expand Up @@ -351,7 +363,9 @@ test("restore with cache found for key", async () => {
{
lookupOnly: false
},
false
false,
undefined,
"",
);

expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
Expand Down Expand Up @@ -393,7 +407,9 @@ test("restore with cache found for restore key", async () => {
{
lookupOnly: false
},
false
false,
undefined,
"",
);

expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
Expand Down Expand Up @@ -434,7 +450,9 @@ test("restore with lookup-only set", async () => {
{
lookupOnly: true
},
false
false,
undefined,
"",
);

expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
Expand Down
16 changes: 12 additions & 4 deletions __tests__/restoreOnly.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ test("restore with no cache found", async () => {
{
lookupOnly: false
},
false
false,
undefined,
"",
);

expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
Expand Down Expand Up @@ -124,7 +126,9 @@ test("restore with restore keys and no cache found", async () => {
{
lookupOnly: false
},
false
false,
undefined,
"",
);

expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
Expand Down Expand Up @@ -163,7 +167,9 @@ test("restore with cache found for key", async () => {
{
lookupOnly: false
},
false
false,
undefined,
"",
);

expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
Expand Down Expand Up @@ -206,7 +212,9 @@ test("restore with cache found for restore key", async () => {
{
lookupOnly: false
},
false
false,
undefined,
"",
);

expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
Expand Down
4 changes: 3 additions & 1 deletion __tests__/save.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ test("save with valid inputs uploads a cache", async () => {
{
uploadChunkSize: 4000000
},
false
false,
undefined,
"",
);

expect(failedMock).toHaveBeenCalledTimes(0);
Expand Down
20 changes: 15 additions & 5 deletions __tests__/saveImpl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ test("save on GHES with AC available", async () => {
{
uploadChunkSize: 4000000
},
false
false,
undefined,
"",
);

expect(failedMock).toHaveBeenCalledTimes(0);
Expand Down Expand Up @@ -266,7 +268,9 @@ test("save with large cache outputs warning", async () => {
[inputPath],
primaryKey,
expect.anything(),
false
false,
undefined,
"",
);

expect(logWarningMock).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -313,7 +317,9 @@ test("save with reserve cache failure outputs warning", async () => {
[inputPath],
primaryKey,
expect.anything(),
false
false,
undefined,
"",
);

expect(logWarningMock).toHaveBeenCalledWith(
Expand Down Expand Up @@ -356,7 +362,9 @@ test("save with server error outputs warning", async () => {
[inputPath],
primaryKey,
expect.anything(),
false
false,
undefined,
"",
);

expect(logWarningMock).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -401,7 +409,9 @@ test("save with valid inputs uploads a cache", async () => {
{
uploadChunkSize: 4000000
},
false
false,
undefined,
"",
);

expect(failedMock).toHaveBeenCalledTimes(0);
Expand Down
8 changes: 6 additions & 2 deletions __tests__/saveOnly.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ test("save with valid inputs uploads a cache", async () => {
{
uploadChunkSize: 4000000
},
false
false,
undefined,
"",
);

expect(failedMock).toHaveBeenCalledTimes(0);
Expand Down Expand Up @@ -131,7 +133,9 @@ test("save failing logs the warning message", async () => {
{
uploadChunkSize: 4000000
},
false
false,
undefined,
"",
);

expect(warningMock).toHaveBeenCalledTimes(1);
Expand Down

0 comments on commit 80a5cc1

Please sign in to comment.