-
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 #47 from GuoXiCheng/dev-c
add gitlab api
- Loading branch information
Showing
11 changed files
with
309 additions
and
98 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { StartTest } from "./helper/start-test"; | ||
|
||
describe('Test Authenticate Gitee', () => { | ||
test('Test Authenticate Gitee', async () => { | ||
const request = StartTest.createGiteeRequest(); | ||
const res = await request.authenticate(); | ||
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' | ||
]) | ||
}); | ||
}); |
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,26 @@ | ||
import { StartTest } from "./helper/start-test"; | ||
|
||
describe('Test Authenticate Github', () => { | ||
test('Test Authenticate Github', async () => { | ||
const request = StartTest.createGithubRequest(); | ||
const res = await request.authenticate(); | ||
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' | ||
]); | ||
}); | ||
}); |
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,50 @@ | ||
import { StartTest } from "./helper/start-test"; | ||
|
||
describe('Test Authenticate Gitlab', () => { | ||
test('Test Authenticate Gitlab', async () => { | ||
const request = StartTest.createGitlabRequest(); | ||
const res = await request.authenticate(); | ||
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 was deleted.
Oops, something went wrong.
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,88 @@ | ||
import { ChatStorage } from "./helper/chat-storage"; | ||
|
||
describe('Use Gitlab Test Chat Storage', () => { | ||
const chatStorage = new ChatStorage(); | ||
|
||
test('Test deleteAll Chat', async () => { | ||
await chatStorage.deleteAll(); | ||
const detail = await chatStorage.find(); | ||
expect(detail.length).toEqual(0); | ||
}); | ||
|
||
test('Test create & findById Chat', async () => { | ||
await chatStorage.create({ | ||
participants: ['test-user', 'test-user-update'], | ||
messages: [ | ||
{ | ||
from: 'test-user', | ||
to: 'test-user-update', | ||
message: 'hello' | ||
} | ||
] | ||
}); | ||
const findResult = await chatStorage.find(); | ||
expect(findResult.length).toEqual(1); | ||
|
||
const findByIdResult = await chatStorage.findById(findResult[0].id); | ||
expect(findByIdResult).toEqual(findResult[0]); | ||
}); | ||
|
||
test('Test updateById Chat', async () => { | ||
const findResult = await chatStorage.find(); | ||
const updateResult = await chatStorage.updateById(findResult[0].id, { | ||
participants: ['test-user', 'test-user-update'], | ||
messages: [ | ||
{ | ||
from: 'test-user', | ||
to: 'test-user-update', | ||
message: 'hello world' | ||
} | ||
] | ||
}); | ||
const findByIdResult = await chatStorage.findById(findResult[0].id); | ||
expect(updateResult.participants).toEqual(findByIdResult.participants); | ||
expect(updateResult.messages).toEqual(findByIdResult.messages); | ||
expect(updateResult.id).toEqual(findByIdResult.id); | ||
expect(updateResult.created_at).toEqual(findByIdResult.created_at); | ||
expect(updateResult.updated_at).toEqual(findByIdResult.updated_at); | ||
}); | ||
|
||
test('Test deleteById Chat failed', async () => { | ||
try { | ||
await chatStorage.deleteById(123); | ||
} catch (error: any) { | ||
expect(error.response.data).toEqual({ | ||
"message": "404 Not found" | ||
}); | ||
} | ||
}); | ||
|
||
test('Test updateById Chat failed', async () => { | ||
try { | ||
await chatStorage.updateById(123, { | ||
participants: ['test-user', 'test-user-update'], | ||
messages: [ | ||
{ | ||
from: 'test-user', | ||
to: 'test-user-update', | ||
message: 'hello world' | ||
} | ||
] | ||
}); | ||
} catch (error: any) { | ||
expect(error.response.data).toEqual({ | ||
"message": "404 Not found" | ||
}); | ||
} | ||
}); | ||
|
||
test('Test findById Chat failed', async () => { | ||
try { | ||
await chatStorage.findById(123); | ||
} catch (error: any) { | ||
expect(error.response.data).toEqual({ | ||
"message": "404 Not found" | ||
}); | ||
} | ||
}); | ||
}); |
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,6 @@ | ||
import { BaseModel } from "../../storage-lib"; | ||
|
||
export interface ChatModel extends BaseModel { | ||
participants: string[]; | ||
messages: Array<{from: string; to: string; message: string}>; | ||
} |
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,13 @@ | ||
import { GitlabStorage } from "../../storage-lib"; | ||
import { ChatModel } from "./chat-model"; | ||
import { StartTest } from "./start-test"; | ||
|
||
const options = { | ||
request: StartTest.createGitlabRequest(), | ||
issueNumber: StartTest.GITLAB_NUMBER | ||
} | ||
export class ChatStorage extends GitlabStorage<ChatModel> { | ||
constructor() { | ||
super(options); | ||
} | ||
} |
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
Oops, something went wrong.