Conversation
Both HTTP clients accept an optional HandlerStack. When one is passed it still gets the retry middleware, the default headers, and the base_uri, so a test can build the stack around a MockHandler plus Guzzle's history middleware and inspect what was actually sent. The new GitLab client test covers the gap #381 exposed: the Bearer header, the User-Agent and Accept headers, the unauthenticated case, project path encoding, note pagination, the concurrent getIssuesByIid() fan-out, the JSON body of a slash command note, and a 503 recovered by the retry middleware. Refs #382 Co-Authored-By: Claude Fable 5.1 <[email protected]>
Replace the anonymous subclass that swapped in a bare Guzzle client with the HandlerStack the constructor now accepts. The client under test keeps its headers, base_uri, cookie jar, and retry middleware, so the test can cover the default headers, the --no-cache headers, cookie persistence across requests, the request URLs, and a 503 recovered by the retry middleware. Refs #382 Co-Authored-By: Claude Fable 5.1 <[email protected]>
initRepo() called exit(1) from inside the command, which no test can
observe. It also never reached that branch: when git rev-parse fails
its output is empty, and realpath('') is the current directory, so
GitRepository opened a non-repository without complaint and the
failure surfaced later as an unrelated GitException.
Check the git process result and throw a RuntimeException. The console
application renders the message and exits 1, so the user-facing exit
code is unchanged.
Refs #382
Co-Authored-By: Claude Fable 5.1 <[email protected]>
…sitory Each test runs a throwaway command inside a fresh temporary directory, with or without a git repository in it, and asserts on the nid, the work item reference, and whether the repository was opened. This covers the regression fixed in #385, where a project#nid or work item URL argument returned before initRepo() ran, along with reading the nid from the branch name and both failure messages. Refs #382 Co-Authored-By: Claude Fable 5.1 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #382
What changed
Both HTTP clients accept an optional
HandlerStack, so tests can wrap aMockHandlerwith Guzzle's history middleware and assert on the requests the client actually sends.IssueCommandBase::initRepo()throws aRuntimeExceptioninstead of callingexit(1), and checks thegit rev-parseresult before opening the repository.Why
#381 changed the GitLab auth header and nothing in the suite noticed. The existing Drupal.org client test swapped in a bare Guzzle client, so it could only test response parsing. #385 fixed a crash in
initialize()that the one placeholder test could not have caught.While making the no-repository path testable, it turned out the old
catchnever fired:realpath('')returns the current directory, so a failedgit rev-parseopened a non-repository and failed later with an unrelatedGitException. The exit code seen by users is still 1.New coverage
GitLab client (
tests/src/GitLab/ClientTest.php)Authorization: Bearer <token>fromDRUPALORG_GITLAB_TOKEN, and no auth header when the variable is unset andglabis offPATHUser-AgentandAcceptproject/drupalencoded asproject%2FdrupalforgetProject(),getIssue(), andpostIssueNote()getIssueNotes()requests page 2 only after a full page of 100getIssuesByIid()maps a 404 and malformed JSON tonullper iidDrupal.org client (
tests/src/ClientTest.php)Cache-Control/Pragmaonly with--no-cacheIssueCommandBase (
tests/src/Command/Issue/IssueCommandBaseTest.php)project#nid, and work item URL all open the repositoryrequiresRepository = falsenever touches git3617735-fix_jsbranchmain, "No repository found" outside a repositoryTesting
Each new header and initialize test was checked by reintroducing the original regression (
PRIVATE-TOKENheader, and the earlyreturnfrom #385) and confirming the suite fails.The 503 retry tests send
Retry-After: 0, so the retry middleware does not sleep.🤖 Generated with Claude Code