Skip to content

Commit

Permalink
fix(app): secrets json schema
Browse files Browse the repository at this point in the history
  • Loading branch information
danadajian committed Nov 15, 2023
1 parent 5c089f7 commit 4f06799
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/backend/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export const updateBaseImagesInputSchema = z.object({
export const secretsJsonSchema = z.record(
z.string(),
z.object({
githubToken: z.string(),
githubApiUrl: z.string()
githubToken: z.string().min(1),
githubApiUrl: z.string().optional()
})
);
export type FetchCurrentPageInput = z.infer<typeof fetchCurrentPageInputSchema>;
Expand Down
16 changes: 16 additions & 0 deletions app/backend/test/getOctokit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ describe('getOctokitOptions', () => {
});
});

it('does not throw if githubApiUrl is not provided', () => {
(readFileSync as jest.Mock).mockImplementation(() => ({
toString: jest.fn(() =>
JSON.stringify({
'github-owner/github-repo': {
githubToken: 'some-token'
}
})
)
}));
getOctokit('github-owner', 'github-repo');
expect(Octokit).toHaveBeenCalledWith({
auth: 'some-token'
});
});

it('throws error if token not found', () => {
(readFileSync as jest.Mock).mockImplementation(() => ({
toString: jest.fn(() => JSON.stringify({}))
Expand Down

0 comments on commit 4f06799

Please sign in to comment.