Skip to content

Commit

Permalink
test: fix testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain committed Jan 30, 2024
1 parent 4b86e19 commit 1a68889
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
12 changes: 4 additions & 8 deletions src/api/controllers/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,9 @@ export function route(hono: THono) {
}
const data = await c.req.json();
if (type === 'app-settings') {
const kvManager = new GitHubKVManager();
await kvManager.setAppSettingById(id, data);
await GitHubKVManager.instance().setAppSettingById(id, data);
} else if (type === 'setting') {
const kvManager = new GitHubKVManager();
await kvManager.setSettingById(id, data);
await GitHubKVManager.instance().setSettingById(id, data);
} else if (type === 'ding-setting') {
const kvManager = new DingKVManager();
await kvManager.setSettingById(id, data);
Expand Down Expand Up @@ -129,11 +127,9 @@ export function route(hono: THono) {
let data = null;

if (type === 'app-settings') {
const kvManager = new GitHubKVManager();
data = await kvManager.getAppSettingById(id);
data = await GitHubKVManager.instance().getAppSettingById(id);
} else if (type === 'setting') {
const kvManager = new GitHubKVManager();
data = await kvManager.getSettingById(id);
data = await GitHubKVManager.instance().getSettingById(id);
} else if (type === 'ding-setting') {
const kvManager = new DingKVManager();
data = await kvManager.getSettingById(id);
Expand Down
6 changes: 1 addition & 5 deletions test/github/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { GitHubService } from '@opensumi/octo-service';

const shouldSkip = !Boolean(process.env['GITHUB_TOKEN']);
console.log(`πŸš€ ~ file: service.test.ts ~ line 5 ~ shouldSkip`, shouldSkip);
jest.setTimeout(20 * 1000);

(shouldSkip ? describe.skip : describe)('can fetch github data', () => {
const octo = new Octokit({
Expand All @@ -15,18 +16,14 @@ console.log(`πŸš€ ~ file: service.test.ts ~ line 5 ~ shouldSkip`, shouldSkip);
service.octo = octo;

it('can fetch history', async () => {
jest.setTimeout(9999999999);

const data = await service.getRepoHistory('opensumi', 'core');
console.log(`πŸš€ ~ file: service.test.ts ~ line 15 ~ it ~ data`, data);
});
it('can get pr info', async () => {
jest.setTimeout(9999999999);
const result = await service.getPrByNumber('opensumi', 'core', 2463);
console.log(`πŸš€ ~ file: service.test.ts:33 ~ it ~ result:`, result);
});
it('can get patch', async () => {
jest.setTimeout(9999999999);
const { data: patch } = await octo.pulls.get({
owner: 'opensumi',
repo: 'core',
Expand All @@ -38,7 +35,6 @@ console.log(`πŸš€ ~ file: service.test.ts ~ line 5 ~ shouldSkip`, shouldSkip);
console.log(`πŸš€ ~ file: service.test.ts:33 ~ it ~ patch:`, patch);
});
it('can get diff', async () => {
jest.setTimeout(9999999999);
const { data: diff } = await octo.pulls.get({
owner: 'opensumi',
repo: 'core',
Expand Down

0 comments on commit 1a68889

Please sign in to comment.