mirror of
https://github.com/facebook/sapling.git
synced 2025-01-06 04:43:19 +03:00
phabstatus: no longer mock unused fields
Summary: I do not know why all of these fields that we never checked were mocked in the fist place. Reviewed By: DurhamG Differential Revision: D6826457 fbshipit-source-id: 78d336940b6146b61684c7789172298497c0b57f
This commit is contained in:
parent
9c0bd152ae
commit
83dd5f6841
@ -95,9 +95,8 @@ class Client(object):
|
||||
if self._mock:
|
||||
response = self._mocked_responses.pop()
|
||||
if 'error_info' in response:
|
||||
raise ClientError(response.get('error_code', None),
|
||||
response['error_info'])
|
||||
ret = {'query': {0: {'results': {'nodes': response['result']}}}}
|
||||
raise ClientError(None, response['error_info'])
|
||||
ret = {'query': {0: {'results': {'nodes': response}}}}
|
||||
else:
|
||||
params = { 'params': { 'numbers': rev_numbers } }
|
||||
ret = self._client.query(timeout, self._getquery(), params)
|
||||
|
@ -33,34 +33,28 @@ Prep configuration
|
||||
Now progressively test the response handling for variations of missing data
|
||||
|
||||
$ cat > $TESTTMP/mockduit << EOF
|
||||
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}],
|
||||
> "result": []
|
||||
> }]
|
||||
> [[]]
|
||||
> EOF
|
||||
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg diff --since-last-arc-diff
|
||||
abort: unable to determine previous changeset hash
|
||||
[255]
|
||||
|
||||
$ cat > $TESTTMP/mockduit << EOF
|
||||
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}],
|
||||
> "result": [{
|
||||
> [[{
|
||||
> "number": 1,
|
||||
> "diff_status_name": "Needs Review",
|
||||
> "differential_diffs": {"count": 3}
|
||||
> }]
|
||||
> }]
|
||||
> }]]
|
||||
> EOF
|
||||
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg diff --since-last-arc-diff
|
||||
abort: unable to determine previous changeset hash
|
||||
[255]
|
||||
|
||||
$ cat > $TESTTMP/mockduit << EOF
|
||||
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}],
|
||||
> "result": [{
|
||||
> [[{
|
||||
> "number": 1,
|
||||
> "diff_status_name": "Needs Review"
|
||||
> }]
|
||||
> }]
|
||||
> }]]
|
||||
> EOF
|
||||
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg diff --since-last-arc-diff
|
||||
abort: unable to determine previous changeset hash
|
||||
@ -70,8 +64,7 @@ This is the case when the diff is up to date with the current commit;
|
||||
there is no diff since what was landed.
|
||||
|
||||
$ cat > $TESTTMP/mockduit << EOF
|
||||
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}],
|
||||
> "result": [{
|
||||
> [[{
|
||||
> "number": 1,
|
||||
> "diff_status_name": "Needs Review",
|
||||
> "latest_active_diff": {
|
||||
@ -82,8 +75,7 @@ there is no diff since what was landed.
|
||||
> }
|
||||
> },
|
||||
> "differential_diffs": {"count": 1}
|
||||
> }]
|
||||
> }]
|
||||
> }]]
|
||||
> EOF
|
||||
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg diff --since-last-arc-diff
|
||||
|
||||
@ -93,8 +85,7 @@ the commit list returned from our mocked phabricator; it is present to
|
||||
assert that we order the commits consistently based on the time field.
|
||||
|
||||
$ cat > $TESTTMP/mockduit << EOF
|
||||
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}],
|
||||
> "result": [{
|
||||
> [[{
|
||||
> "number": 1,
|
||||
> "diff_status_name": "Needs Review",
|
||||
> "latest_active_diff": {
|
||||
@ -105,8 +96,7 @@ assert that we order the commits consistently based on the time field.
|
||||
> }
|
||||
> },
|
||||
> "differential_diffs": {"count": 1}
|
||||
> }]
|
||||
> }]
|
||||
> }]]
|
||||
> EOF
|
||||
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg diff --since-last-arc-diff --nodates
|
||||
diff -r 88dd5a13bf28 foo
|
||||
|
@ -26,13 +26,13 @@ Configure arc...
|
||||
And now with bad responses:
|
||||
|
||||
$ cat > $TESTTMP/mockduit << EOF
|
||||
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}], "result": {}}]
|
||||
> [{}]
|
||||
> EOF
|
||||
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{phabstatus}\n' -r .
|
||||
Error
|
||||
|
||||
$ cat > $TESTTMP/mockduit << EOF
|
||||
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}], "error_info": "failed, yo"}]
|
||||
> [{"error_info": "failed, yo"}]
|
||||
> EOF
|
||||
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{phabstatus}\n' -r .
|
||||
Error talking to phabricator. No diff information can be provided.
|
||||
@ -42,9 +42,7 @@ And now with bad responses:
|
||||
Missing status field is treated as an error
|
||||
|
||||
$ cat > $TESTTMP/mockduit << EOF
|
||||
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}],
|
||||
> "result": [{"number": 1}]
|
||||
> }]
|
||||
> [[{"number": 1}]]
|
||||
> EOF
|
||||
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{phabstatus}\n' -r . 2>&1 | grep KeyError
|
||||
KeyError: 'diff_status_name'
|
||||
@ -52,9 +50,7 @@ Missing status field is treated as an error
|
||||
And finally, the success case
|
||||
|
||||
$ cat > $TESTTMP/mockduit << EOF
|
||||
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}],
|
||||
> "result": [{"number": 1, "diff_status_name": "Needs Review"}]
|
||||
> }]
|
||||
> [[{"number": 1, "diff_status_name": "Needs Review"}]]
|
||||
> EOF
|
||||
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{phabstatus}\n' -r .
|
||||
Needs Review
|
||||
@ -62,9 +58,7 @@ And finally, the success case
|
||||
Make sure the code works without the smartlog extensions
|
||||
|
||||
$ cat > $TESTTMP/mockduit << EOF
|
||||
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}],
|
||||
> "result": [{"number": 1, "diff_status_name": "Needs Review"}]
|
||||
> }]
|
||||
> [[{"number": 1, "diff_status_name": "Needs Review"}]]
|
||||
> EOF
|
||||
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg --config 'extensions.smartlog=!' log -T '{phabstatus}\n' -r .
|
||||
Needs Review
|
||||
|
@ -26,13 +26,13 @@ Configure arc...
|
||||
And now with bad responses:
|
||||
|
||||
$ cat > $TESTTMP/mockduit << EOF
|
||||
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}], "result": {}}]
|
||||
> [{}]
|
||||
> EOF
|
||||
$ OVERRIDE_GRAPHQL_URI=https://a.com HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{syncstatus}\n' -r .
|
||||
Error
|
||||
|
||||
$ cat > $TESTTMP/mockduit << EOF
|
||||
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}], "error_info": "failed, yo"}]
|
||||
> [{"error_info": "failed, yo"}]
|
||||
> EOF
|
||||
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{syncstatus}\n' -r .
|
||||
Error talking to phabricator. No diff information can be provided.
|
||||
@ -42,8 +42,7 @@ And now with bad responses:
|
||||
Missing status field is treated as an error
|
||||
|
||||
$ cat > $TESTTMP/mockduit << EOF
|
||||
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}],
|
||||
> "result": [{
|
||||
> [[{
|
||||
> "number": 1,
|
||||
> "latest_active_diff": {
|
||||
> "local_commit_info": {
|
||||
@ -53,8 +52,7 @@ Missing status field is treated as an error
|
||||
> }
|
||||
> },
|
||||
> "differential_diffs": {"count": 3}
|
||||
> }]
|
||||
> }]
|
||||
> }]]
|
||||
> EOF
|
||||
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{syncstatus}\n' -r . 2>&1 | grep Error
|
||||
KeyError: 'diff_status_name'
|
||||
@ -62,8 +60,7 @@ Missing status field is treated as an error
|
||||
Missing count field is treated as an error
|
||||
|
||||
$ cat > $TESTTMP/mockduit << EOF
|
||||
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}],
|
||||
> "result": [{
|
||||
> [[{
|
||||
> "number": 1,
|
||||
> "diff_status_name": "Approved",
|
||||
> "latest_active_diff": {
|
||||
@ -73,8 +70,7 @@ Missing count field is treated as an error
|
||||
> ]
|
||||
> }
|
||||
> }
|
||||
> }]
|
||||
> }]
|
||||
> }]]
|
||||
> EOF
|
||||
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{syncstatus}\n' -r . 2>&1 | grep Error
|
||||
KeyError: 'differential_diffs'
|
||||
@ -82,8 +78,7 @@ Missing count field is treated as an error
|
||||
Missing hash field is treated as unsync
|
||||
|
||||
$ cat > $TESTTMP/mockduit << EOF
|
||||
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}],
|
||||
> "result": [{
|
||||
> [[{
|
||||
> "number": 1,
|
||||
> "diff_status_name": "Approved",
|
||||
> "latest_active_diff": {
|
||||
@ -94,8 +89,7 @@ Missing hash field is treated as unsync
|
||||
> }
|
||||
> },
|
||||
> "differential_diffs": {"count": 3}
|
||||
> }]
|
||||
> }]
|
||||
> }]]
|
||||
> EOF
|
||||
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{syncstatus}\n' -r .
|
||||
unsync
|
||||
@ -103,8 +97,7 @@ Missing hash field is treated as unsync
|
||||
And finally, the success case
|
||||
|
||||
$ cat > $TESTTMP/mockduit << EOF
|
||||
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}],
|
||||
> "result": [{
|
||||
> [[{
|
||||
> "number": 1,
|
||||
> "diff_status_name": "Committed",
|
||||
> "latest_active_diff": {
|
||||
@ -115,8 +108,7 @@ And finally, the success case
|
||||
> }
|
||||
> },
|
||||
> "differential_diffs": {"count": 3}
|
||||
> }]
|
||||
> }]
|
||||
> }]]
|
||||
> EOF
|
||||
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{syncstatus}\n' -r .
|
||||
committed
|
||||
|
Loading…
Reference in New Issue
Block a user