cli/pkg/cmd/attestation/auth/host_test.go
Meredith Lancaster 139e82c68c Revert "temporarily skip non-failing tests"
This reverts commit de8778797f.
2025-04-09 07:23:17 -06:00

52 lines
943 B
Go

package auth
import (
"testing"
ghauth "github.com/cli/go-gh/v2/pkg/auth"
"github.com/stretchr/testify/require"
)
func TestIsHostSupported(t *testing.T) {
testcases := []struct {
name string
expectedErr bool
host string
}{
{
name: "Default github.com host",
expectedErr: false,
host: "github.com",
},
{
name: "Localhost",
expectedErr: false,
host: "github.localhost",
},
{
name: "No host set",
expectedErr: false,
host: "",
},
{
name: "GHE tenant host",
expectedErr: false,
host: "some-tenant.ghe.com",
},
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
t.Setenv("GH_HOST", tc.host)
host, _ := ghauth.DefaultHost()
err := IsHostSupported(host)
if tc.expectedErr {
require.ErrorIs(t, err, ErrUnsupportedHost)
} else {
require.NoError(t, err)
}
})
}
}