mirror of
https://github.com/facebook/sapling.git
synced 2025-01-04 03:06:30 +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}
|
||||
> }]
|
||||
> }]
|
||||
> [[{
|
||||
> "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"
|
||||
> }]
|
||||
> }]
|
||||
> [[{
|
||||
> "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,20 +64,18 @@ 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": {
|
||||
> "local_commit_info": {
|
||||
> "nodes": [
|
||||
> {"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"2e6531b7dada2a3e5638e136de05f51e94a427f4\"}}"}
|
||||
> ]
|
||||
> }
|
||||
> },
|
||||
> "differential_diffs": {"count": 1}
|
||||
> }]
|
||||
> }]
|
||||
> [[{
|
||||
> "number": 1,
|
||||
> "diff_status_name": "Needs Review",
|
||||
> "latest_active_diff": {
|
||||
> "local_commit_info": {
|
||||
> "nodes": [
|
||||
> {"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"2e6531b7dada2a3e5638e136de05f51e94a427f4\"}}"}
|
||||
> ]
|
||||
> }
|
||||
> },
|
||||
> "differential_diffs": {"count": 1}
|
||||
> }]]
|
||||
> EOF
|
||||
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg diff --since-last-arc-diff
|
||||
|
||||
@ -93,20 +85,18 @@ 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": {
|
||||
> "local_commit_info": {
|
||||
> "nodes": [
|
||||
> {"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"88dd5a13bf28b99853a24bddfc93d4c44e07c6bd\"}}"}
|
||||
> ]
|
||||
> }
|
||||
> },
|
||||
> "differential_diffs": {"count": 1}
|
||||
> }]
|
||||
> }]
|
||||
> [[{
|
||||
> "number": 1,
|
||||
> "diff_status_name": "Needs Review",
|
||||
> "latest_active_diff": {
|
||||
> "local_commit_info": {
|
||||
> "nodes": [
|
||||
> {"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"88dd5a13bf28b99853a24bddfc93d4c44e07c6bd\"}}"}
|
||||
> ]
|
||||
> }
|
||||
> },
|
||||
> "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,19 +42,17 @@ 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": {
|
||||
> "nodes": [
|
||||
> {"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"lolwut\"}}"}
|
||||
> ]
|
||||
> }
|
||||
> },
|
||||
> "differential_diffs": {"count": 3}
|
||||
> }]
|
||||
> }]
|
||||
> [[{
|
||||
> "number": 1,
|
||||
> "latest_active_diff": {
|
||||
> "local_commit_info": {
|
||||
> "nodes": [
|
||||
> {"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"lolwut\"}}"}
|
||||
> ]
|
||||
> }
|
||||
> },
|
||||
> "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,19 +60,17 @@ 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": {
|
||||
> "local_commit_info": {
|
||||
> "nodes": [
|
||||
> {"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"lolwut\"}}"}
|
||||
> ]
|
||||
> }
|
||||
> [[{
|
||||
> "number": 1,
|
||||
> "diff_status_name": "Approved",
|
||||
> "latest_active_diff": {
|
||||
> "local_commit_info": {
|
||||
> "nodes": [
|
||||
> {"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"lolwut\"}}"}
|
||||
> ]
|
||||
> }
|
||||
> }]
|
||||
> }]
|
||||
> }
|
||||
> }]]
|
||||
> EOF
|
||||
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{syncstatus}\n' -r . 2>&1 | grep Error
|
||||
KeyError: 'differential_diffs'
|
||||
@ -82,20 +78,18 @@ 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": {
|
||||
> "local_commit_info": {
|
||||
> "nodes": [
|
||||
> {"property_value": "{\"lolwut\": {\"time\": 0}}"}
|
||||
> ]
|
||||
> }
|
||||
> },
|
||||
> "differential_diffs": {"count": 3}
|
||||
> }]
|
||||
> }]
|
||||
> [[{
|
||||
> "number": 1,
|
||||
> "diff_status_name": "Approved",
|
||||
> "latest_active_diff": {
|
||||
> "local_commit_info": {
|
||||
> "nodes": [
|
||||
> {"property_value": "{\"lolwut\": {\"time\": 0}}"}
|
||||
> ]
|
||||
> }
|
||||
> },
|
||||
> "differential_diffs": {"count": 3}
|
||||
> }]]
|
||||
> EOF
|
||||
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{syncstatus}\n' -r .
|
||||
unsync
|
||||
@ -103,20 +97,18 @@ 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": {
|
||||
> "local_commit_info": {
|
||||
> "nodes": [
|
||||
> {"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"lolwut\"}}"}
|
||||
> ]
|
||||
> }
|
||||
> },
|
||||
> "differential_diffs": {"count": 3}
|
||||
> }]
|
||||
> }]
|
||||
> [[{
|
||||
> "number": 1,
|
||||
> "diff_status_name": "Committed",
|
||||
> "latest_active_diff": {
|
||||
> "local_commit_info": {
|
||||
> "nodes": [
|
||||
> {"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"lolwut\"}}"}
|
||||
> ]
|
||||
> }
|
||||
> },
|
||||
> "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