Merge pull request #11142 from cli/bump-go-to-1.24

Bump go to 1.24
This commit is contained in:
William Martin 2025-06-17 12:04:08 +02:00 committed by GitHub
commit fe3bf3eeca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 17 additions and 47 deletions

4
go.mod
View file

@ -1,8 +1,8 @@
module github.com/cli/cli/v2
go 1.23.0
go 1.24
toolchain go1.23.5
toolchain go1.24.4
require (
github.com/AlecAivazis/survey/v2 v2.3.7

View file

@ -23,15 +23,14 @@ import (
"github.com/cli/cli/v2/pkg/iostreams"
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestNewCmdExtension(t *testing.T) {
tempDir := t.TempDir()
oldWd, _ := os.Getwd()
localExtensionTempDir := filepath.Join(tempDir, "gh-hello")
assert.NoError(t, os.MkdirAll(localExtensionTempDir, 0755))
assert.NoError(t, os.Chdir(localExtensionTempDir))
t.Cleanup(func() { _ = os.Chdir(oldWd) })
require.NoError(t, os.MkdirAll(localExtensionTempDir, 0755))
t.Chdir(localExtensionTempDir)
tests := []struct {
name string

View file

@ -1251,9 +1251,10 @@ func TestManager_repo_not_found(t *testing.T) {
}
func TestManager_Create(t *testing.T) {
chdirTemp(t)
tempDir := t.TempDir()
t.Chdir(tempDir)
err := os.MkdirAll("gh-test", 0755)
assert.NoError(t, err)
require.NoError(t, err)
ios, _, stdout, stderr := iostreams.Test()
@ -1279,9 +1280,10 @@ func TestManager_Create(t *testing.T) {
}
func TestManager_Create_go_binary(t *testing.T) {
chdirTemp(t)
tempDir := t.TempDir()
t.Chdir(tempDir)
err := os.MkdirAll("gh-test", 0755)
assert.NoError(t, err)
require.NoError(t, err)
reg := httpmock.Registry{}
defer reg.Verify(t)
@ -1329,9 +1331,10 @@ func TestManager_Create_go_binary(t *testing.T) {
}
func TestManager_Create_other_binary(t *testing.T) {
chdirTemp(t)
tempDir := t.TempDir()
t.Chdir(tempDir)
err := os.MkdirAll("gh-test", 0755)
assert.NoError(t, err)
require.NoError(t, err)
ios, _, stdout, stderr := iostreams.Test()
@ -1392,18 +1395,6 @@ func Test_ensurePrefixed(t *testing.T) {
}
}
// chdirTemp changes the current working directory to a temporary directory for the duration of the test.
func chdirTemp(t *testing.T) {
oldWd, _ := os.Getwd()
tempDir := t.TempDir()
if err := os.Chdir(tempDir); err != nil {
t.Fatal(err)
}
t.Cleanup(func() {
_ = os.Chdir(oldWd)
})
}
func fileNames(files []os.DirEntry) []string {
names := make([]string, len(files))
for i, f := range files {

View file

@ -174,11 +174,6 @@ func Test_NewCmdDownload(t *testing.T) {
}
func Test_downloadRun(t *testing.T) {
oldwd, err := os.Getwd()
if err != nil {
t.Fatalf("could not determine working directory: %v", err)
}
tests := []struct {
name string
isTTY bool
@ -526,11 +521,7 @@ func Test_downloadRun(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tempDir := t.TempDir()
if err := os.Chdir(tempDir); err == nil {
t.Cleanup(func() { _ = os.Chdir(oldwd) })
} else {
t.Fatal(err)
}
t.Chdir(tempDir)
ios, _, stdout, stderr := iostreams.Test()
ios.SetStdoutTTY(tt.isTTY)

View file

@ -210,17 +210,10 @@ func createTestDir(t *testing.T) (cleanupFn func()) {
rootDir := t.TempDir()
// Move workspace to temporary directory
cwd, err := os.Getwd()
if err != nil {
t.Fatal(err)
}
err = os.Chdir(rootDir)
if err != nil {
t.Fatal(err)
}
t.Chdir(rootDir)
// Make subdirectories
err = os.Mkdir(filepath.Join(rootDir, "subDir1"), 0755)
err := os.Mkdir(filepath.Join(rootDir, "subDir1"), 0755)
if err != nil {
t.Fatal(err)
}
@ -253,10 +246,6 @@ func createTestDir(t *testing.T) (cleanupFn func()) {
cleanupFn = func() {
os.RemoveAll(rootDir)
err = os.Chdir(cwd)
if err != nil {
t.Fatal(err)
}
}
return cleanupFn
}