@@ -22,6 +22,13 @@ func withFastPoll(t *testing.T) {
2222 t .Cleanup (func () { pollInterval = origInterval })
2323}
2424
25+ func withNoBrowser (t * testing.T ) {
26+ t .Helper ()
27+ orig := openBrowserFunc
28+ openBrowserFunc = func (url string ) error { return nil }
29+ t .Cleanup (func () { openBrowserFunc = orig })
30+ }
31+
2532func TestStartAuthSession_Success (t * testing.T ) {
2633 server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
2734 assert .Equal (t , "POST" , r .Method )
@@ -300,6 +307,7 @@ func TestPollOnce_InvalidJSON(t *testing.T) {
300307
301308func TestLoginInteractive_SuccessRFC3339 (t * testing.T ) {
302309 withFastPoll (t )
310+ withNoBrowser (t )
303311 tmpDir := t .TempDir ()
304312 t .Setenv ("HOME" , tmpDir )
305313
@@ -340,6 +348,7 @@ func TestLoginInteractive_SuccessRFC3339(t *testing.T) {
340348
341349func TestLoginInteractive_SuccessSQLiteFormat (t * testing.T ) {
342350 withFastPoll (t )
351+ withNoBrowser (t )
343352 tmpDir := t .TempDir ()
344353 t .Setenv ("HOME" , tmpDir )
345354
@@ -369,6 +378,7 @@ func TestLoginInteractive_SuccessSQLiteFormat(t *testing.T) {
369378}
370379
371380func TestLoginInteractive_StartAuthSessionError (t * testing.T ) {
381+ withNoBrowser (t )
372382 tmpDir := t .TempDir ()
373383 t .Setenv ("HOME" , tmpDir )
374384
@@ -385,6 +395,7 @@ func TestLoginInteractive_StartAuthSessionError(t *testing.T) {
385395
386396func TestLoginInteractive_PollForApprovalError (t * testing.T ) {
387397 withFastPoll (t )
398+ withNoBrowser (t )
388399 tmpDir := t .TempDir ()
389400 t .Setenv ("HOME" , tmpDir )
390401
@@ -409,6 +420,7 @@ func TestLoginInteractive_PollForApprovalError(t *testing.T) {
409420
410421func TestLoginInteractive_InvalidExpirationFormat (t * testing.T ) {
411422 withFastPoll (t )
423+ withNoBrowser (t )
412424 tmpDir := t .TempDir ()
413425 t .Setenv ("HOME" , tmpDir )
414426
@@ -438,6 +450,7 @@ func TestLoginInteractive_InvalidExpirationFormat(t *testing.T) {
438450
439451func TestLoginInteractive_SaveTokenError (t * testing.T ) {
440452 withFastPoll (t )
453+ withNoBrowser (t )
441454 tmpDir := t .TempDir ()
442455 authDir := filepath .Join (tmpDir , ".openboot" )
443456 require .NoError (t , os .MkdirAll (authDir , 0500 ))
@@ -473,6 +486,7 @@ func TestLoginInteractive_SaveTokenError(t *testing.T) {
473486
474487func TestLoginInteractive_CreatedAtTimestamp (t * testing.T ) {
475488 withFastPoll (t )
489+ withNoBrowser (t )
476490 tmpDir := t .TempDir ()
477491 t .Setenv ("HOME" , tmpDir )
478492
@@ -506,6 +520,7 @@ func TestLoginInteractive_CreatedAtTimestamp(t *testing.T) {
506520
507521func TestLoginInteractive_TokenPersisted (t * testing.T ) {
508522 withFastPoll (t )
523+ withNoBrowser (t )
509524 tmpDir := t .TempDir ()
510525 t .Setenv ("HOME" , tmpDir )
511526
@@ -551,6 +566,7 @@ func TestGetAPIBase_EnvOverride(t *testing.T) {
551566
552567func TestLoginInteractive_MultiplePolls (t * testing.T ) {
553568 withFastPoll (t )
569+ withNoBrowser (t )
554570
555571 tmpDir := t .TempDir ()
556572 t .Setenv ("HOME" , tmpDir )
@@ -626,6 +642,7 @@ func TestPollForApproval_QueryParameter(t *testing.T) {
626642
627643func TestLoginInteractive_ExpiresAtParsing (t * testing.T ) {
628644 withFastPoll (t )
645+ withNoBrowser (t )
629646 tmpDir := t .TempDir ()
630647 t .Setenv ("HOME" , tmpDir )
631648
@@ -686,6 +703,7 @@ func TestPollOnce_UnknownStatus(t *testing.T) {
686703
687704func TestLoginInteractive_EmptyUsername (t * testing.T ) {
688705 withFastPoll (t )
706+ withNoBrowser (t )
689707 tmpDir := t .TempDir ()
690708 t .Setenv ("HOME" , tmpDir )
691709
0 commit comments