Skip to content

Pass web browser to each individual command#3279

Merged
mislav merged 2 commits intotrunkfrom
browser-refactor
Mar 30, 2021
Merged

Pass web browser to each individual command#3279
mislav merged 2 commits intotrunkfrom
browser-refactor

Conversation

@mislav
Copy link
Copy Markdown
Contributor

@mislav mislav commented Mar 22, 2021

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 comment commands 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.sum are so large! It might be because I am using Go 1.16 locally.

mislav added 2 commits March 19, 2021 21:22
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.
@mislav mislav requested a review from a team March 22, 2021 11:57
Copy link
Copy Markdown
Contributor

@samcoe samcoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! I like how much easier it is to verify browsed URLs in tests.

@samcoe samcoe mentioned this pull request Mar 24, 2021
@mislav mislav merged commit 44ae7ae into trunk Mar 30, 2021
@mislav mislav deleted the browser-refactor branch March 30, 2021 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants