-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for cache verification
Context: #81 (comment) Co-authored-by: Gregor Martynus <[email protected]>
- Loading branch information
1 parent
c4320eb
commit fb4f95c
Showing
3 changed files
with
99 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
node_modules | ||
coverage | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { request } from "@octokit/request"; | ||
import { fetchVerificationKeys } from "./index.js"; | ||
|
||
async function main() { | ||
const token = process.env.GITHUB_TOKEN; | ||
if (!token) throw new Error("GITHUB_TOKEN is not defined"); | ||
|
||
const r = request.defaults({ | ||
headers: { | ||
Authorization: `token ${token}`, | ||
} | ||
}); | ||
|
||
const { id, keys } = await fetchVerificationKeys({ token }); | ||
const cache = { id, keys }; | ||
|
||
const firstRateLimitCheck = await r("GET /rate_limit"); | ||
const firstRateLimitRemaining = firstRateLimitCheck.data.resources.core.remaining; | ||
console.log("Rate limit after fetching keys:", firstRateLimitRemaining); | ||
|
||
const response = await fetchVerificationKeys({ token, cache }); | ||
|
||
const secondRateLimitCheck = await r("GET /rate_limit"); | ||
const secondRateLimitRemaining = secondRateLimitCheck.data.resources.core.remaining; | ||
console.log("Rate limit after fetching keys from cache:", secondRateLimitRemaining); | ||
} | ||
|
||
main().catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters