-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from GuoXiCheng/dev-c
Dev c
- Loading branch information
Showing
10 changed files
with
185 additions
and
77 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
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
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,23 +1,94 @@ | ||
import { StartTest } from "./helper/start-test"; | ||
|
||
test('Test Ping Gitee', async () => { | ||
const request = StartTest.getGiteeRequest(); | ||
const res = await request.ping("gitee"); | ||
expect(Object.keys(res)).toEqual([ | ||
'id', 'login', | ||
'name', 'avatar_url', | ||
'url', 'html_url', | ||
'remark', 'followers_url', | ||
'following_url', 'gists_url', | ||
'starred_url', 'subscriptions_url', | ||
'organizations_url', 'repos_url', | ||
'events_url', 'received_events_url', | ||
'type', 'blog', | ||
'weibo', 'bio', | ||
'public_repos', 'public_gists', | ||
'followers', 'following', | ||
'stared', 'watched', | ||
'created_at', 'updated_at', | ||
'email' | ||
]); | ||
}, 30000); | ||
describe('Test Ping Function', () => { | ||
test('Test Ping Gitee', async () => { | ||
const request = StartTest.getGiteeRequest(); | ||
const res = await request.ping("gitee"); | ||
expect(Object.keys(res)).toEqual([ | ||
'id', 'login', | ||
'name', 'avatar_url', | ||
'url', 'html_url', | ||
'remark', 'followers_url', | ||
'following_url', 'gists_url', | ||
'starred_url', 'subscriptions_url', | ||
'organizations_url', 'repos_url', | ||
'events_url', 'received_events_url', | ||
'type', 'blog', | ||
'weibo', 'bio', | ||
'public_repos', 'public_gists', | ||
'followers', 'following', | ||
'stared', 'watched', | ||
'created_at', 'updated_at', | ||
'email' | ||
]); | ||
}); | ||
test('Test Ping Github', async () => { | ||
const request = StartTest.getGithubRequest(); | ||
const res = await request.ping("github"); | ||
expect(Object.keys(res)).toEqual([ | ||
'login', 'id', | ||
'node_id', 'avatar_url', | ||
'gravatar_id', 'url', | ||
'html_url', 'followers_url', | ||
'following_url', 'gists_url', | ||
'starred_url', 'subscriptions_url', | ||
'organizations_url', 'repos_url', | ||
'events_url', 'received_events_url', | ||
'type', 'site_admin', | ||
'name', 'company', | ||
'blog', 'location', | ||
'email', 'hireable', | ||
'bio', 'twitter_username', | ||
'public_repos', 'public_gists', | ||
'followers', 'following', | ||
'created_at', 'updated_at' | ||
]); | ||
}); | ||
test('Test Ping Gitlab', async () => { | ||
const request = StartTest.getGitlabRequest(); | ||
const res = await request.ping("gitlab"); | ||
expect(Object.keys(res)).toEqual([ | ||
'id', | ||
'username', | ||
'name', | ||
'state', | ||
'locked', | ||
'avatar_url', | ||
'web_url', | ||
'created_at', | ||
'bio', | ||
'location', | ||
'public_email', | ||
'skype', | ||
'linkedin', | ||
'twitter', | ||
'discord', | ||
'website_url', | ||
'organization', | ||
'job_title', | ||
'pronouns', | ||
'bot', | ||
'work_information', | ||
'local_time', | ||
'last_sign_in_at', | ||
'confirmed_at', | ||
'last_activity_on', | ||
'email', | ||
'theme_id', | ||
'color_scheme_id', | ||
'projects_limit', | ||
'current_sign_in_at', | ||
'identities', | ||
'can_create_group', | ||
'can_create_project', | ||
'two_factor_enabled', | ||
'external', | ||
'private_profile', | ||
'commit_email', | ||
'shared_runners_minutes_limit', | ||
'extra_shared_runners_minutes_limit', | ||
'scim_identities' | ||
]); | ||
}); | ||
}); | ||
|
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
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
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
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,32 @@ | ||
import { StoragePlatform } from "../enums"; | ||
import { RequestInstance, StoragePlatformUserMap } from "./interfaces"; | ||
|
||
export abstract class TinyRequest { | ||
constructor( | ||
protected instance: RequestInstance, | ||
protected baseUrl: string, | ||
protected accessToken: string | ||
) { } | ||
|
||
abstract get<T>(url: string): Promise<T>; | ||
abstract post(url: string): void; | ||
|
||
async ping<P extends keyof typeof StoragePlatform>(platform: P): Promise<StoragePlatformUserMap[typeof StoragePlatform[P]]> { | ||
let url: string; | ||
switch (platform) { | ||
case StoragePlatform.gitee: | ||
url = `${this.baseUrl}/api/v5/user`; | ||
break; | ||
case StoragePlatform.github: | ||
url = `${this.baseUrl}/user`; | ||
break; | ||
case StoragePlatform.gitlab: | ||
url = `${this.baseUrl}/api/v3/user`; | ||
break; | ||
default: | ||
throw new Error('Unsupported platform'); | ||
} | ||
|
||
return this.get<StoragePlatformUserMap[typeof StoragePlatform[P]]>(url); | ||
} | ||
} |
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
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
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