Skip to content

Commit e9f9bcc

Browse files
committed
fix(tests): make mocks for rest octokit async
1 parent 0d25379 commit e9f9bcc

File tree

12 files changed

+13
-13
lines changed

12 files changed

+13
-13
lines changed

source/app/action/index.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ function quit(reason) {
185185
//Test token validity and requests count
186186
else if (!/^NOT_NEEDED$/.test(token)) {
187187
//Check rate limit
188-
const {data} = await api.rest.request("GET /rate_limit", {}).catch(() => ({data:{resources:{}}}))
188+
const {data} = await api.rest.rateLimit.get().catch(() => ({data:{resources:{}}}))
189189
Object.assign(resources, data.resources)
190190
info("API requests (REST)", resources.core ? `${resources.core.remaining}/${resources.core.limit}` : "(unknown)")
191191
info("API requests (GraphQL)", resources.graphql ? `${resources.graphql.remaining}/${resources.graphql.limit}` : "(unknown)")
@@ -600,7 +600,7 @@ function quit(reason) {
600600
info.break()
601601
info.section("Consumed API requests")
602602
info(" * provided that no other app used your quota during execution", "")
603-
const {data:current} = await rest.request("GET /rate_limit", {}).catch(() => ({data:{resources:{}}}))
603+
const {data:current} = await rest.rateLimit.get().catch(() => ({data:{resources:{}}}))
604604
for (const type of ["core", "graphql", "search"]) {
605605
const used = resources[type].remaining - current.resources[type].remaining
606606
info({core:"REST API", graphql:"GraphQL API", search:"Search API"}[type], (Number.isFinite(used)&&(used >= 0)) ? used : "(unknown)")

tests/mocks/api/github/rest/activity/listEventsForAuthenticatedUser.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**Mocked data */
2-
export default function({ faker }, target, that, [{ username: login, page, per_page }]) {
2+
export default async function({ faker }, target, that, [{ username: login, page, per_page }]) {
33
console.debug("metrics/compute/mocks > mocking rest api result > rest.activity.listEventsForAuthenticatedUser")
44
return ({
55
status: 200,

tests/mocks/api/github/rest/activity/listRepoEvents.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import listEventsForAuthenticatedUser from "./listEventsForAuthenticatedUser.mjs"
33

44
/**Mocked data */
5-
export default function({ faker }, target, that, [{ username: login, page, per_page }]) {
5+
export default async function({ faker }, target, that, [{ username: login, page, per_page }]) {
66
console.debug("metrics/compute/mocks > mocking rest api result > rest.activity.listRepoEvents")
77
return listEventsForAuthenticatedUser(...arguments)
88
}

tests/mocks/api/github/rest/emojis/get.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**Mocked data */
2-
export default function({ faker }, target, that) {
2+
export default async function({ faker }, target, that) {
33
console.debug("metrics/compute/mocks > mocking rest api result > rest.emojis.get")
44
return ({
55
status: 200,

tests/mocks/api/github/rest/rateLimit/get.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**Mocked data */
2-
export default function({ faker }, target, that, args) {
2+
export default async function({ faker }, target, that, args) {
33
return ({
44
status: 200,
55
url: "https://api.github.com/rate_limit",

tests/mocks/api/github/rest/repos/getContributorsStats.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**Mocked data */
2-
export default function({ faker }, target, that, [{ owner, repo }]) {
2+
export default async function({ faker }, target, that, [{ owner, repo }]) {
33
console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.getContributorsStats")
44
return ({
55
status: 200,

tests/mocks/api/github/rest/repos/getViews.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**Mocked data */
2-
export default function({ faker }, target, that, [{ owner, repo }]) {
2+
export default async function({ faker }, target, that, [{ owner, repo }]) {
33
console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.getViews")
44
const count = faker.datatype.number(10000) * 2
55
const uniques = faker.datatype.number(count) * 2

tests/mocks/api/github/rest/repos/listCommits.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**Mocked data */
2-
export default function({ faker }, target, that, [{ page, per_page, owner, repo }]) {
2+
export default async function({ faker }, target, that, [{ page, per_page, owner, repo }]) {
33
console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.listCommits")
44
return ({
55
status: 200,

tests/mocks/api/github/rest/repos/listContributors.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**Mocked data */
2-
export default function({ faker }, target, that, [{ owner, repo }]) {
2+
export default async function({ faker }, target, that, [{ owner, repo }]) {
33
console.debug("metrics/compute/mocks > mocking rest api result > rest.repos.listContributors")
44
return ({
55
status: 200,

tests/mocks/api/github/rest/request.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**Mocked data */
2-
export default function({ faker }, target, that, args) {
2+
export default async function({ faker }, target, that, args) {
33
//Arguments
44
const [url] = args
55
//Head request

0 commit comments

Comments
 (0)