Skip to content

Commit

Permalink
fix: add return type to mock responses
Browse files Browse the repository at this point in the history
  • Loading branch information
adelkahomolova committed Oct 21, 2019
1 parent 662d541 commit 005b592
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 23 deletions.
19 changes: 11 additions & 8 deletions src/services/bitbucket/BitbucketService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ export class BitbucketService implements ICVSService {
id: val.destination.repository.uuid,
owner: {
login: <string>val.destination.repository.full_name.split('/').shift(),
id: <string>(await this.client.users.get({ username: `${val.destination.repository.full_name.split('/').shift()}` })).data.uuid,
id: <string>(await this.client.users.get({ username: `${val.destination.repository.full_name.split('/').shift()}` })).data.uuid
? <string>(await this.client.users.get({ username: `${val.destination.repository.full_name.split('/').shift()}` })).data.uuid
: 'undefined',
url: url.concat(`/${val.destination.repository.full_name.split('/').shift()}`),
},
},
Expand Down Expand Up @@ -125,13 +127,14 @@ export class BitbucketService implements ICVSService {
user: {
id: response.data.author.uuid,
login: response.data.author.nickname,
url: response.data.author.website,
url: response.data.author.links.html.href,
},
url: response.data.links.html.href,
body: response.data.summary.raw,
createdAt: response.data.created_on,
updatedAt: response.data.updated_on,
closedAt: response.data.closed_by.created_on,
//TODO
closedAt: 'undefined',
//TODO
mergedAt: null,
state: response.data.state,
Expand Down Expand Up @@ -165,7 +168,7 @@ export class BitbucketService implements ICVSService {
const response = <DeepRequired<Bitbucket.Response<BitbucketCommit>>>await this.client.pullrequests.listCommits(params);

const items = response.data.values.map((val) => ({
sha: val.sha,
sha: val.hash,
commit: {
url: val.links.html.href,
message: val.message,
Expand Down Expand Up @@ -227,7 +230,7 @@ export class BitbucketService implements ICVSService {
user: {
login: response.data.reporter.nickname,
id: response.data.reporter.uuid,
url: response.data.reporter.href,
url: response.data.reporter.links.html.href,
},
url: response.data.links.html.href,
body: response.data.content.raw,
Expand Down Expand Up @@ -256,10 +259,10 @@ export class BitbucketService implements ICVSService {
url: val.user.links.html.href,
},
url: val.links.html.href,
body: val.content.raw,
body: val.content.raw ? val.content.raw : 'undefined',
createdAt: val.created_on,
updatedAt: val.updated_on,
authorAssociation: val.author_association,
updatedAt: val.updated_on ? val.updated_on : 'undefined',
authorAssociation: val.author_association ? val.author_association : 'undefined',
id: val.id,
}));
const pagination = this.getPagination(response.data);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export const getIssueCommentsResponse = {
import { IssueComment } from '../../model';
import { Paginated } from '../../../../inspectors/common/Paginated';

export const getIssueCommentsResponse: Paginated<IssueComment> = {
items: [
{
user: {
Expand All @@ -7,10 +10,10 @@ export const getIssueCommentsResponse = {
url: 'https://bitbucket.org/%7Bdfa073eb-c602-4740-83ef-a8fe8ee03dfd%7D/',
},
url: 'https://bitbucket.org/pypy/pypy/issues/3086#comment-54230712',
body: undefined,
body: 'undefined',
createdAt: '2019-10-07T06:12:23.627201+00:00',
updatedAt: undefined,
authorAssociation: undefined,
updatedAt: 'undefined',
authorAssociation: 'undefined',
id: 54230712,
},
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
export const getIssueResponse = {
import { Issue } from '../../model';

export const getIssueResponse: Issue = {
id: '{54220cd1-b139-4188-9455-1e13e663f1ac}',
user: { login: 'stefanor', id: '{dfa073eb-c602-4740-83ef-a8fe8ee03dfd}', url: undefined },
user: {
login: 'stefanor',
id: '{dfa073eb-c602-4740-83ef-a8fe8ee03dfd}',
url: 'https://bitbucket.org/%7Bdfa073eb-c602-4740-83ef-a8fe8ee03dfd%7D/',
},
url: 'https://bitbucket.org/pypy/pypy/issues/3086/arm64-jit-lots-of-crashes',
body:
'As mentioned on IRC over the last few days.\r\n\r\nWhen I translate a JIT pypy2.7 from the 7.2 release branch \\(or hg HEAD\\) under cPython on arm64, I get an interpreter with an unstable JIT. It constantly crashes, with some variant of:\r\n\r\n```\r\n$ pypy/goal/pypy-c lib_pypy/_sqlite3_build.py\r\nRPython traceback:\r\n File "rpython_jit_metainterp_10.c", line 25430, in send_loop_to_backend\r\n File "rpython_jit_backend_aarch64.c", line 1690, in AssemblerARM64_assemble_loop\r\n File "rpython_jit_backend_aarch64.c", line 4551, in AssemblerARM64__assemble\r\n File "rpython_jit_backend_aarch64.c", line 13381, in AssemblerARM64__walk_operations\r\n File "rpython_jit_backend_aarch64.c", line 52643, in ResOpAssembler_emit_op_zero_array\r\nFatal RPython error: AssertionError\r\n```\r\n\r\n`--jit off` works as usual.\r\n\r\nI can’t reproduce this with the pre-built [pypy2.7-v7.2.0rc0-aarch64.tar.bz2](https://bitbucket.org/pypy/pypy/downloads/pypy2.7-v7.2.0rc0-aarch64.tar.bz2), and it can translate pypy2.7 to produce a working JIT. OS is Debian sid. Haven’t tried pypy3.6, yet.\r\n\r\nFull build log attached. No toolchain details in there, but it will be almost identical to [this build, without JIT](https://buildd.debian.org/status/fetch.php?pkg=pypy3&arch=arm64&ver=7.2.0%7Erc1%2Bdfsg-1&stamp=1570132096&raw=0).\r\n\r\nHardware: kvm guest on an APM [X-Gene 1](https://www.gigabyte.com/Server-Motherboard/MP30-AR1-rev-11#ov) \\(a Mustang, something like that\\)',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export const getIssuesResponse = {
import { Issue } from '../../model';
import { Paginated } from '../../../../inspectors/common/Paginated';

export const getIssuesResponse: Paginated<Issue> = {
items: [
{
user: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
export const getPullCommits = {
import { PullCommits } from '../../model';
import { Paginated } from '../../../../inspectors/common/Paginated';

export const getPullCommits: Paginated<PullCommits> = {
items: [
{
sha: undefined,
sha: 'f799951483319e5397d41019de50f8e07b01b04f',
commit: {
url: 'https://bitbucket.org/ashwinahuja/pypy/commits/f799951483319e5397d41019de50f8e07b01b04f',
message: 'Remove the duplicated (unnecessary items)',
Expand All @@ -14,7 +17,7 @@ export const getPullCommits = {
},
},
{
sha: undefined,
sha: '0e3d572c47c60df4760e541da6a05e5e305d6175',
commit: {
url: 'https://bitbucket.org/ashwinahuja/pypy/commits/0e3d572c47c60df4760e541da6a05e5e305d6175',
message: 'Making datetime objects more compatible with old C extensions written for CPython',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
export const getPullRequestResponse = {
user: { id: '{9d65d517-4898-47ac-9d2f-fd902d25d9f6}', login: 'landtuna', url: undefined },
import { PullRequest } from '../../model';

export const getPullRequestResponse: PullRequest = {
user: {
id: '{9d65d517-4898-47ac-9d2f-fd902d25d9f6}',
login: 'landtuna',
url: 'https://bitbucket.org/%7B9d65d517-4898-47ac-9d2f-fd902d25d9f6%7D/',
},
url: 'https://bitbucket.org/pypy/pypy/pull-requests/1',
body: 'Added a floor() ufunc to micronumpy',
createdAt: '2011-06-22T19:44:39.555192+00:00',
updatedAt: '2011-06-23T13:52:30.230741+00:00',
closedAt: undefined,
closedAt: 'undefined',
mergedAt: null,
state: 'DECLINED',
id: 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export const getPullRequestsResponse = {
import { Paginated } from '../../../../inspectors/common/Paginated';
import { PullRequest } from '../../model';

export const getPullRequestsResponse: Paginated<PullRequest> = {
items: [
{
user: {
Expand All @@ -19,7 +22,7 @@ export const getPullRequestsResponse = {
url: 'https://bitbucket.org/pypy/pypy',
name: 'pypy',
id: '{54220cd1-b139-4188-9455-1e13e663f1ac}',
owner: { id: undefined, login: 'pypy', url: 'www.bitbucket.org/pypy' },
owner: { id: 'undefined', login: 'pypy', url: 'www.bitbucket.org/pypy' },
},
},
},
Expand Down

0 comments on commit 005b592

Please sign in to comment.