Pass web browser to each individual command#3279
Merged
Conversation
This removes sensitivity to the BROWSER environment variable in tests and makes it easier to verify the URL that the browser was invoked with without having to stub sub-processes.
samcoe
approved these changes
Mar 22, 2021
Closed
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.
This removes sensitivity to the BROWSER environment variable in tests and makes it easier to verify the URL that the browser was invoked with without having to stub sub-processes.
It introduces a concept of a "browser" that is passed to every command. The command may invoke the browser's
Browse(url)method to open the URL. In tests, a mock browser is passed to commands.Ultimately, the runtime browser implementation comes from github.com/cli/browser.
Part of #3044
Paves the way for #858
Credit goes to @samcoe who pioneered this approach by making
issue/pr commentcommands accept a func to open the browser 155507d#diff-72e7588e84e2b2979396d12650b539b17dc973040668846512b544dd4e34592f. As a consequence, those commands were the easiest to port over to the more generic browser object and did not require any test changes at all 🎉No idea why the changes to
go.sumare so large! It might be because I am using Go 1.16 locally.