Skip to content

Commit

Permalink
override octokit system for runBlock and runPreset tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg committed Dec 20, 2024
1 parent 125b13c commit d5ec03e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions packages/create/src/runners/runBlock.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Octokit } from "octokit";
import { describe, expect, test, vi } from "vitest";
import { z } from "zod";

Expand All @@ -12,7 +13,10 @@ const base = createBase({

function createSystem() {
return {
fetcher: noop("fetcher"),
fetchers: {
fetch: noop("fetcher"),
octokit: {} as Octokit,
},
fs: {
readFile: noop("readFile"),
writeDirectory: vi.fn(),
Expand All @@ -27,7 +31,7 @@ function noop(label: string) {
}

describe("runBlock", () => {
test("Block without Addons", async () => {
test.only("Block without Addons", async () => {
const block = base.createBlock({
produce({ options }) {
return {
Expand Down
5 changes: 4 additions & 1 deletion packages/create/src/runners/runPreset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ const base = createBase({

function createSystem() {
return {
fetcher: noop("fetcher"),
fetchers: {
fetch: noop("fetcher"),
octokit: {} as Octokit,

Check failure on line 17 in packages/create/src/runners/runPreset.test.ts

View workflow job for this annotation

GitHub Actions / Lint

Cannot find name 'Octokit'.

Check failure on line 17 in packages/create/src/runners/runPreset.test.ts

View workflow job for this annotation

GitHub Actions / Build

Cannot find name 'Octokit'.

Check failure on line 17 in packages/create/src/runners/runPreset.test.ts

View workflow job for this annotation

GitHub Actions / Test

Cannot find name 'Octokit'.
},
fs: {
readFile: noop("readFile"),
writeDirectory: vi.fn(),
Expand Down
5 changes: 4 additions & 1 deletion packages/create/src/system/createSystemContextWithAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import {
export async function createSystemContextWithAuth(
settings: SystemContextSettings,
) {
const authToken = settings.auth ? undefined : await getGitHubAuthToken();
const authToken =
settings.fetchers?.octokit || settings.auth
? undefined
: await getGitHubAuthToken();
const auth = authToken?.succeeded ? authToken.token : settings.auth;

return createSystemContext({ ...settings, auth });
Expand Down

0 comments on commit d5ec03e

Please sign in to comment.