Skip to content

Commit 871dc2a

Browse files
authored
chore(deps): bump Go version to v1.25.0 (#508)
Changes: - Bump Go version to the latest v1.25.0 - Fix a storage import test by using platform-agnostic err checks. Previously the test used a platform-specific error message. The behaviour changed in Go 1.25 due to https://go-review.googlesource.com/c/go/+/671458 and broke the test on Windows. --------- Signed-off-by: Ville Vesilehto <ville.vesilehto@upcloud.com>
1 parent f785bfa commit 871dc2a

2 files changed

Lines changed: 23 additions & 25 deletions

File tree

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module github.com/UpCloudLtd/upcloud-cli/v3
22

3-
go 1.24.0
4-
5-
toolchain go1.24.2
3+
go 1.25.0
64

75
require (
86
github.com/UpCloudLtd/progress v1.0.3

internal/commands/storage/import_test.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package storage
22

33
import (
44
"io"
5+
"io/fs"
56
"net/url"
67
"os"
7-
"runtime"
88
"slices"
99
"strings"
1010
"testing"
@@ -59,17 +59,12 @@ func TestImportCommand(t *testing.T) {
5959
State: upcloud.StorageImportStateCompleted,
6060
}
6161

62-
fileNotFoundErr := "cannot get file size: stat testfile: no such file or directory"
63-
if runtime.GOOS == "windows" {
64-
fileNotFoundErr = "cannot get file size: CreateFile testfile: The system cannot find the file specified."
65-
}
66-
6762
for _, test := range []struct {
68-
name string
69-
args []string
70-
error string
71-
request request.CreateStorageImportRequest
72-
windowsError string
63+
name string
64+
args []string
65+
error string
66+
expectFileNotExist bool
67+
request request.CreateStorageImportRequest
7368
}{
7469
{
7570
name: "source is missing",
@@ -127,7 +122,7 @@ func TestImportCommand(t *testing.T) {
127122
"--zone", "fi-hel1",
128123
"--title", "test-2",
129124
},
130-
error: fileNotFoundErr,
125+
expectFileNotExist: true,
131126
},
132127
} {
133128
t.Run(test.name, func(t *testing.T) {
@@ -146,8 +141,13 @@ func TestImportCommand(t *testing.T) {
146141
c.Cobra().SetArgs(test.args)
147142
_, err := mockexecute.MockExecute(c, mService, conf)
148143

149-
if test.error != "" {
150-
assert.EqualError(t, err, test.error)
144+
if test.error != "" || test.expectFileNotExist {
145+
assert.Error(t, err)
146+
if test.expectFileNotExist {
147+
assert.ErrorIs(t, err, fs.ErrNotExist)
148+
} else {
149+
assert.EqualError(t, err, test.error)
150+
}
151151
} else {
152152
assert.NoError(t, err)
153153

@@ -169,7 +169,7 @@ func TestParseSource(t *testing.T) {
169169
name string
170170
input string
171171
expectedError string
172-
expectedWindowsError string
172+
expectFileNotExist bool
173173
expectedSourceType string
174174
expectedFileSize int64
175175
expectedParsedURLScheme string
@@ -191,10 +191,9 @@ func TestParseSource(t *testing.T) {
191191
expectedParsedURLPath: "tempfile",
192192
},
193193
{
194-
name: "local non-existent file",
195-
input: "foobar",
196-
expectedError: "cannot get file size: stat foobar: no such file or directory",
197-
expectedWindowsError: "cannot get file size: CreateFile foobar: The system cannot find the file specified.",
194+
name: "local non-existent file",
195+
input: "foobar",
196+
expectFileNotExist: true,
198197
},
199198
{
200199
name: "remote http url",
@@ -240,9 +239,10 @@ func TestParseSource(t *testing.T) {
240239
} else {
241240
purl, stype, fsize, err = parseSource(test.input)
242241
}
243-
if test.expectedError != "" {
244-
if test.expectedWindowsError != "" && runtime.GOOS == "windows" {
245-
assert.EqualError(t, err, test.expectedWindowsError)
242+
if test.expectedError != "" || test.expectFileNotExist {
243+
assert.Error(t, err)
244+
if test.expectFileNotExist {
245+
assert.ErrorIs(t, err, fs.ErrNotExist)
246246
} else {
247247
assert.EqualError(t, err, test.expectedError)
248248
}

0 commit comments

Comments
 (0)