From 168d1eac87c5d23d88a075a8e04a49583fa711f6 Mon Sep 17 00:00:00 2001
From: dhvcc <1337kwiz@gmail.com>
Date: Mon, 4 Apr 2022 15:20:52 +0300
Subject: [PATCH] Fix tests and rebuild

---
 __tests__/cache-restore.test.ts | 15 ++++++++-------
 dist/cache-save/index.js        |  4 ++--
 dist/setup/index.js             |  4 ++--
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/__tests__/cache-restore.test.ts b/__tests__/cache-restore.test.ts
index 55cc571b..99b674ef 100644
--- a/__tests__/cache-restore.test.ts
+++ b/__tests__/cache-restore.test.ts
@@ -193,12 +193,12 @@ virtualenvs.path = "{cache-dir}/virtualenvs"  # /Users/patrick/Library/Caches/py
 
   describe('Check if handleMatchResult', () => {
     it.each([
-      ['pip', '3.8.12', 'requirements.txt', 'someKey', true],
-      ['pipenv', '3.9.1', 'requirements.txt', 'someKey', true],
-      ['poetry', '3.8.12', 'requirements.txt', 'someKey', true],
-      ['pip', '3.9.2', 'requirements.txt', undefined, false],
-      ['pipenv', '3.8.12', 'requirements.txt', undefined, false],
-      ['poetry', '3.9.12', 'requirements.txt', undefined, false]
+      ['pip', '3.8.12', 'requirements.txt', 'someKey', 'someKey', true],
+      ['pipenv', '3.9.1', 'requirements.txt', 'someKey', 'someKey', true],
+      ['poetry', '3.8.12', 'requirements.txt', 'someKey', 'someKey', true],
+      ['pip', '3.9.2', 'requirements.txt', undefined, 'someKey', false],
+      ['pipenv', '3.8.12', 'requirements.txt', undefined, 'someKey', false],
+      ['poetry', '3.9.12', 'requirements.txt', undefined, 'someKey', false]
     ])(
       'sets correct outputs',
       async (
@@ -206,6 +206,7 @@ virtualenvs.path = "{cache-dir}/virtualenvs"  # /Users/patrick/Library/Caches/py
         pythonVersion,
         dependencyFile,
         matchedKey,
+        restoredKey,
         expectedOutputValue
       ) => {
         const cacheDistributor = getCacheDistributor(
@@ -213,7 +214,7 @@ virtualenvs.path = "{cache-dir}/virtualenvs"  # /Users/patrick/Library/Caches/py
           pythonVersion,
           dependencyFile
         );
-        cacheDistributor.handleMatchResult(matchedKey);
+        cacheDistributor.handleMatchResult(matchedKey, restoredKey);
         expect(setOutputSpy).toHaveBeenCalledWith(
           'cache-hit',
           expectedOutputValue
diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js
index 12ea09fe..c1c654f2 100644
--- a/dist/cache-save/index.js
+++ b/dist/cache-save/index.js
@@ -37238,14 +37238,14 @@ class CacheDistributor {
         });
     }
     handleMatchResult(matchedKey, primaryKey) {
-        if (matchedKey == primaryKey) {
+        if (matchedKey) {
             core.saveState(State.CACHE_MATCHED_KEY, matchedKey);
             core.info(`Cache restored from key: ${matchedKey}`);
         }
         else {
             core.info(`${this.packageManager} cache is not found`);
         }
-        core.setOutput('cache-hit', Boolean(matchedKey));
+        core.setOutput('cache-hit', matchedKey === primaryKey);
     }
 }
 exports.default = CacheDistributor;
diff --git a/dist/setup/index.js b/dist/setup/index.js
index b7c14185..e4c20d1a 100644
--- a/dist/setup/index.js
+++ b/dist/setup/index.js
@@ -42583,14 +42583,14 @@ class CacheDistributor {
         });
     }
     handleMatchResult(matchedKey, primaryKey) {
-        if (matchedKey == primaryKey) {
+        if (matchedKey) {
             core.saveState(State.CACHE_MATCHED_KEY, matchedKey);
             core.info(`Cache restored from key: ${matchedKey}`);
         }
         else {
             core.info(`${this.packageManager} cache is not found`);
         }
-        core.setOutput('cache-hit', Boolean(matchedKey));
+        core.setOutput('cache-hit', matchedKey === primaryKey);
     }
 }
 exports.default = CacheDistributor;