@@ -1590,9 +1590,7 @@ func TestSubmit_PreflightCheck_404_BailsOut(t *testing.T) {
15901590 },
15911591 }
15921592
1593- // Use an OAuth token so the PAT pre-flight check passes and we
1594- // exercise the ListStacks 404 path.
1595- setTestTokenForHost (cfg , "gho_test_oauth_token" )
1593+ setTestRepo (cfg )
15961594
15971595 cmd := SubmitCmd (cfg )
15981596 cmd .SetArgs ([]string {"--auto" })
@@ -1645,9 +1643,7 @@ func TestSubmit_PreflightCheck_404_Interactive_UserDeclinesAborts(t *testing.T)
16451643 },
16461644 }
16471645
1648- // Use an OAuth token so the PAT pre-flight check passes and we
1649- // exercise the ListStacks 404 path.
1650- setTestTokenForHost (cfg , "gho_test_oauth_token" )
1646+ setTestRepo (cfg )
16511647
16521648 cmd := SubmitCmd (cfg )
16531649 cmd .SetArgs ([]string {"--auto" })
@@ -2345,91 +2341,6 @@ func TestSubmit_NoTemplate_UsesFooter(t *testing.T) {
23452341 assert .Contains (t , capturedBody , feedbackURL )
23462342}
23472343
2348- func TestSubmit_PreflightCheck_PAT_BailsOut (t * testing.T ) {
2349- s := stack.Stack {
2350- Trunk : stack.BranchRef {Branch : "main" },
2351- Branches : []stack.BranchRef {
2352- {Branch : "b1" },
2353- {Branch : "b2" },
2354- },
2355- }
2356-
2357- tmpDir := t .TempDir ()
2358- writeStackFile (t , tmpDir , s )
2359-
2360- pushed := false
2361- mock := newSubmitMock (tmpDir , "b1" )
2362- mock .PushFn = func (string , []string , bool , bool ) error {
2363- pushed = true
2364- return nil
2365- }
2366- restore := git .SetOps (mock )
2367- defer restore ()
2368-
2369- listStacksCalled := false
2370- cfg , _ , errR := config .NewTestConfig ()
2371- cfg .GitHubClientOverride = & github.MockClient {
2372- ListStacksFn : func () ([]github.RemoteStack , error ) {
2373- listStacksCalled = true
2374- return nil , nil
2375- },
2376- }
2377-
2378- // Simulate a classic PAT — the pre-flight check should abort.
2379- setTestTokenForHost (cfg , "ghp_classic_pat_token" )
2380-
2381- cmd := SubmitCmd (cfg )
2382- cmd .SetArgs ([]string {"--auto" })
2383- cmd .SetOut (io .Discard )
2384- cmd .SetErr (io .Discard )
2385- err := cmd .Execute ()
2386-
2387- cfg .Err .Close ()
2388- errOut , _ := io .ReadAll (errR )
2389- output := string (errOut )
2390-
2391- assert .ErrorIs (t , err , ErrStacksUnavailable )
2392- assert .Contains (t , output , "Personal access tokens are not supported by gh stack" )
2393- assert .Contains (t , output , "gh auth login" )
2394- assert .False (t , pushed , "should not push when using a PAT" )
2395- assert .False (t , listStacksCalled , "should not call ListStacks when PAT detected" )
2396- }
2397-
2398- func TestSubmit_PreflightCheck_FinegrainedPAT_BailsOut (t * testing.T ) {
2399- s := stack.Stack {
2400- Trunk : stack.BranchRef {Branch : "main" },
2401- Branches : []stack.BranchRef {
2402- {Branch : "b1" },
2403- {Branch : "b2" },
2404- },
2405- }
2406-
2407- tmpDir := t .TempDir ()
2408- writeStackFile (t , tmpDir , s )
2409-
2410- mock := newSubmitMock (tmpDir , "b1" )
2411- restore := git .SetOps (mock )
2412- defer restore ()
2413-
2414- cfg , _ , errR := config .NewTestConfig ()
2415- cfg .GitHubClientOverride = & github.MockClient {}
2416-
2417- setTestTokenForHost (cfg , "github_pat_11AABBCC_xxxx" )
2418-
2419- cmd := SubmitCmd (cfg )
2420- cmd .SetArgs ([]string {"--auto" })
2421- cmd .SetOut (io .Discard )
2422- cmd .SetErr (io .Discard )
2423- err := cmd .Execute ()
2424-
2425- cfg .Err .Close ()
2426- errOut , _ := io .ReadAll (errR )
2427- output := string (errOut )
2428-
2429- assert .ErrorIs (t , err , ErrStacksUnavailable )
2430- assert .Contains (t , output , "Personal access tokens are not supported by gh stack" )
2431- }
2432-
24332344func TestSubmit_DisablesAutoMergeOnExistingPR (t * testing.T ) {
24342345 s := stack.Stack {
24352346 Trunk : stack.BranchRef {Branch : "main" },
0 commit comments