We should be writing unit-like tests to ensure our hook_project_src_info() and hook_project_src_releases() implementations return the information we expect. This could be difficult because we need to "inject" the GitHub API. We might be able to "mock" it by explicitly keeping GitHub API disabled in the test case and writing our own github_api_client() function in a test-only submodule to return our own mock GitHub API object.
Also, we may as well do end-to-end testing by doing the same above, but doing a series of xpath queries against the returned XML, checking the content type of the download files.
After this is complete, we should roll a beta.
Comments
Comment #1
iamEAP commentedAdding tests for snapshot releases. Still much to do (see below). Still, marking needs review to ensure the actual testing methodology (which is pretty wonky) works with TestBot. Tests seem to be working on local.
Things this covers
Things this doesn't cover, but that it should
Comment #3
iamEAP commented1: project_src_github-add_automated_tests-2129369-1.patch queued for re-testing.
Comment #5
iamEAP commentedWas hoping a push to the 7.x-1.x branch (with a blank test file) would force a rebuild of this module's dependencies in TestBot, but that may have broken in upgrading to 7.x. I also can't manually trigger a branch-based test. Hopefully will take care of itself by tomorrow.
Patch is virtually identical to #1, just up to latest HEAD (which includes the blank test file I added + the .info changes required).
Comment #7
iamEAP commented5: project_src_github-add_automated_tests-2129369-5.patch queued for re-testing.
Comment #9
iamEAP commented5: project_src_github-add_automated_tests-2129369-5.patch queued for re-testing.
Comment #11
iamEAP commentedComment #12
iamEAP commented5: project_src_github-add_automated_tests-2129369-5.patch queued for re-testing.
Comment #14
iamEAP commentedQuoting my list of todos and crossing off what's done in this patch. Still some to go.
Things left to do
Some project metadata is not validated (api version, recommended/supported/default major version, status,and link)Some release metadata is not validated (release link and status)No work at all has gone into verifying file XML structureor actual file content types/sizes,No work at all has gone into verifying any non-dev (e.g. properly tagged) releases and associated release xml metadata validation,The remaining tests are more directly file-related, so I may break them off into a separate class, or at least a separate testmethod.
Comment #16
iamEAP commented14: project_src_github-add_automated_tests-2129369-14.patch queued for re-testing.
Comment #18
jtwalters commentedWish I could help somehow but I've never written tests before. :)
Comment #19
iamEAP commented14: project_src_github-add_automated_tests-2129369-14.patch queued for re-testing.
Comment #20
iamEAP commentedHere's #14 again with latest head.
Comment #22
iamEAP commentedAfter playing around on Travis, I think I've determined the solution to the problems that occur here: https://travis-ci.org/iamEAP/project_src_github/builds/14124616
Apparently the actual public file system according to the test environment is at sites/default/files, while the parent environment is at /sites/default/files/simpletest/###. We can manually delete the "file_public_path" variable in the test set up to force it to properly handle tar files.
With that in mind, we just need to take care of the following remaining tasks:
Comment #23
iamEAP commentedLet's see how testbot likes these file tests. If it works, we'll just have to ensure that our .info file package changes are working as expected.
Comment #25
iamEAP commentedGotta add a --binary flag when generating the diff.
Comment #27
iamEAP commentedDid not completely implement the "project_src_github_domain" variable across all tests. Fix here.
Next up, .info packaging verification.
Comment #28
iamEAP commentedAnd finally, adding checks for tagged release / branch release .info file packaging.
Comment #30
iamEAP commentedGuessing TestBot doesn't like to file_get_contents() remote URLs. We'll try drupal_http_request().
Comment #32
iamEAP commentedComment #34
iamEAP commentedNeed to use the getAbsoluteUrl() method rather than appending the path to $GLOBALS['base_url'].
Should do the trick.
Comment #36
iamEAP commentedMay as well do some debug while the testbot queue is lean.
Comment #38
iamEAP commentedIssue appears to be that the .info file contains the drupal release history URL as if it clean URLs weren't enabled. Adding a manual variable set on that variable here.
Comment #39
iamEAP commentedGood start for automated tests. We'll see if any additional need arises. Committed db1fbc7