sapling/tests/test-phabstatus.t
Oguz Ulgen 585ede8a25 Add sync status and change the conduit call to differential.querydiffhashes
Summary:
1) Add sync status
2) Combine sync status and phab status to use one unified conduit call,
i.e. differential.querydiffhashes

Test Plan:
cd hg-crew
make local
cd ../fb-hgext
make local
cd tests
../../hg-crew/tests/run-tests.py test-phabstatus.t
../../hg-crew/tests/run-tests.py test-syncstatus.t

Reviewers: wqfish, lcharignon, #sourcecontrol, wez, ttung, rmcelroy

Reviewed By: rmcelroy

Subscribers: rmcelroy, mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D3651915

Tasks: 10100400

Signature: t1:3651915:1470340328:bf003006f6afe9b86a40f204e150e0d12350c21d
2016-08-05 11:33:36 -07:00

60 lines
1.8 KiB
Perl

Setup
$ PYTHONPATH=$TESTDIR/..:$PYTHONPATH
$ export PYTHONPATH
$ cat >> $HGRCPATH << EOF
> [extensions]
> arcconfig=$TESTDIR/../phabricator/arcconfig.py
> phabstatus=$TESTDIR/../hgext3rd/phabstatus.py
> smartlog=$TESTDIR/../hgext3rd/smartlog.py
> EOF
$ hg init repo
$ cd repo
$ touch foo
$ hg ci -qAm 'Differential Revision: https://phabricator.fb.com/D1'
With an invalid arc configuration
$ hg log -T '{phabstatus}\n' -r .
arcconfig configuration problem. No diff information can be provided.
Error info: no .arcconfig foundError
Configure arc...
$ echo '{}' > .arcconfig
$ echo '{}' > .arcrc
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"}]
> EOF
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{phabstatus}\n' -r .
Error talking to phabricator. No diff information can be provided.
Error info: failed, yoError
Missing status field is treated as an error
$ cat > $TESTTMP/mockduit << EOF
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}],
> "result": {"1" : {"hash": "this is the best hash ewa"}}}]
> EOF
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{phabstatus}\n' -r .
Error
And finally, the success case
$ cat > $TESTTMP/mockduit << EOF
> [{"cmd": ["differential.querydiffhashes", {"revisionIDs": ["1"]}],
> "result": {"1" : {"count": 1, "status": "Needs Review", "hash": "lolwut"}}}]
> EOF
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -T '{phabstatus}\n' -r .
Needs Review