@@ -11,6 +11,11 @@ import (
1111)
1212
1313func TestWorkflowData_PinContext_SkipHardcodedFallback (t * testing.T ) {
14+ originalDefaultHost := getDefaultGHHost ()
15+ t .Cleanup (func () {
16+ SetDefaultGHHost (originalDefaultHost )
17+ })
18+
1419 t .Run ("sets SkipHardcodedFallback when GH_HOST is a non-github.qkg1.top host" , func (t * testing.T ) {
1520 t .Setenv ("GH_HOST" , "myorg.ghe.com" )
1621
@@ -33,6 +38,7 @@ func TestWorkflowData_PinContext_SkipHardcodedFallback(t *testing.T) {
3338
3439 t .Run ("does not set SkipHardcodedFallback when GH_HOST is not set" , func (t * testing.T ) {
3540 require .NoError (t , os .Unsetenv ("GH_HOST" ))
41+ SetDefaultGHHost ("" )
3642
3743 d := & WorkflowData {}
3844 ctx := d .PinContext ()
@@ -41,6 +47,28 @@ func TestWorkflowData_PinContext_SkipHardcodedFallback(t *testing.T) {
4147 assert .False (t , ctx .SkipHardcodedFallback , "Expected SkipHardcodedFallback to be false when GH_HOST is not set" )
4248 })
4349
50+ t .Run ("sets SkipHardcodedFallback when default GH host is a non-github.qkg1.top host" , func (t * testing.T ) {
51+ require .NoError (t , os .Unsetenv ("GH_HOST" ))
52+ SetDefaultGHHost ("myorg.ghe.com" )
53+
54+ d := & WorkflowData {}
55+ ctx := d .PinContext ()
56+
57+ require .NotNil (t , ctx )
58+ assert .True (t , ctx .SkipHardcodedFallback , "Expected SkipHardcodedFallback to be true when default GH host is a GHE host" )
59+ })
60+
61+ t .Run ("does not set SkipHardcodedFallback when default GH host is github.com" , func (t * testing.T ) {
62+ require .NoError (t , os .Unsetenv ("GH_HOST" ))
63+ SetDefaultGHHost ("github.com" )
64+
65+ d := & WorkflowData {}
66+ ctx := d .PinContext ()
67+
68+ require .NotNil (t , ctx )
69+ assert .False (t , ctx .SkipHardcodedFallback , "Expected SkipHardcodedFallback to be false when default GH host is github.com" )
70+ })
71+
4472 t .Run ("returns nil for nil WorkflowData" , func (t * testing.T ) {
4573 var d * WorkflowData
4674 ctx := d .PinContext ()
0 commit comments