Skip to content

Commit f21e902

Browse files
authored
Merge pull request #1963 from dearchap/issue_1962
Fix:(issue_1962) Fix tests failing on 32 bit architectures
2 parents a4832fd + 2a37495 commit f21e902

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

altsrc/yaml_file_loader_test.go

+12-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package altsrc_test
33
import (
44
"errors"
55
"fmt"
6-
"io/ioutil"
76
"log"
87
"os"
98
"testing"
@@ -90,7 +89,7 @@ func ExampleApp_Run_yamlFileLoaderDuration() {
9089
}
9190

9291
func TestYamlFileInt64Slice(t *testing.T) {
93-
_ = ioutil.WriteFile("current.yaml", []byte(`top:
92+
_ = os.WriteFile("current.yaml", []byte(`top:
9493
test: [100, 9223372036854775808]`), 0666)
9594
defer os.Remove("current.yaml")
9695

@@ -110,7 +109,7 @@ func TestYamlFileInt64Slice(t *testing.T) {
110109
}
111110

112111
func TestYamlFileStringSlice(t *testing.T) {
113-
_ = ioutil.WriteFile("current.yaml", []byte(`top:
112+
_ = os.WriteFile("current.yaml", []byte(`top:
114113
test: ["s1", "s2"]`), 0666)
115114
defer os.Remove("current.yaml")
116115

@@ -143,7 +142,7 @@ func TestYamlFileUint64(t *testing.T) {
143142
}{
144143
{
145144
"top.test",
146-
`top:
145+
`top:
147146
test: 100`,
148147
false,
149148
},
@@ -169,7 +168,7 @@ func TestYamlFileUint64(t *testing.T) {
169168
},
170169
{
171170
"test",
172-
"test: 9223372036854775808", //uintt64
171+
"test: 9223372036854775808", //uint64
173172
false,
174173
},
175174
{
@@ -180,7 +179,7 @@ func TestYamlFileUint64(t *testing.T) {
180179
}
181180

182181
for i, test := range tests {
183-
_ = ioutil.WriteFile("current.yaml", []byte(test.entry), 0666)
182+
_ = os.WriteFile("current.yaml", []byte(test.entry), 0666)
184183
defer os.Remove("current.yaml")
185184

186185
testFlag := []cli.Flag{
@@ -207,7 +206,7 @@ func TestYamlFileUint(t *testing.T) {
207206
}{
208207
{
209208
"top.test",
210-
`top:
209+
`top:
211210
test: 100`,
212211
false,
213212
},
@@ -228,12 +227,12 @@ func TestYamlFileUint(t *testing.T) {
228227
},
229228
{
230229
"test",
231-
"test: 9223372036854775807", //int
230+
"test: 775807", //int
232231
false,
233232
},
234233
{
235234
"test",
236-
"test: 9223372036854775808", //uintt64
235+
"test: 4775808", //uint64
237236
false,
238237
},
239238
{
@@ -244,7 +243,7 @@ func TestYamlFileUint(t *testing.T) {
244243
}
245244

246245
for i, test := range tests {
247-
_ = ioutil.WriteFile("current.yaml", []byte(test.entry), 0666)
246+
_ = os.WriteFile("current.yaml", []byte(test.entry), 0666)
248247
defer os.Remove("current.yaml")
249248

250249
testFlag := []cli.Flag{
@@ -271,7 +270,7 @@ func TestYamlFileInt64(t *testing.T) {
271270
}{
272271
{
273272
"top.test",
274-
`top:
273+
`top:
275274
test: 100`,
276275
false,
277276
},
@@ -297,7 +296,7 @@ func TestYamlFileInt64(t *testing.T) {
297296
},
298297
{
299298
"test",
300-
"test: 9223372036854775808", //uintt64
299+
"test: 9223372036854775808", //uint64
301300
true,
302301
},
303302
{
@@ -308,7 +307,7 @@ func TestYamlFileInt64(t *testing.T) {
308307
}
309308

310309
for i, test := range tests {
311-
_ = ioutil.WriteFile("current.yaml", []byte(test.entry), 0666)
310+
_ = os.WriteFile("current.yaml", []byte(test.entry), 0666)
312311
defer os.Remove("current.yaml")
313312

314313
testFlag := []cli.Flag{

flag_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func TestFlagsFromEnv(t *testing.T) {
199199
{"1", 1, &IntFlag{Name: "seconds", EnvVars: []string{"SECONDS"}}, ""},
200200
{"08", 8, &IntFlag{Name: "seconds", EnvVars: []string{"SECONDS"}, Base: 10}, ""},
201201
{"755", 493, &IntFlag{Name: "seconds", EnvVars: []string{"SECONDS"}, Base: 8}, ""},
202-
{"deadBEEF", 3735928559, &IntFlag{Name: "seconds", EnvVars: []string{"SECONDS"}, Base: 16}, ""},
202+
{"dBEEF", 900847, &IntFlag{Name: "seconds", EnvVars: []string{"SECONDS"}, Base: 16}, ""},
203203
{"08", 0, &IntFlag{Name: "seconds", EnvVars: []string{"SECONDS"}, Base: 0}, `could not parse "08" as int value from environment variable "SECONDS" for flag seconds: .*`},
204204
{"1.2", 0, &IntFlag{Name: "seconds", EnvVars: []string{"SECONDS"}}, `could not parse "1.2" as int value from environment variable "SECONDS" for flag seconds: .*`},
205205
{"foobar", 0, &IntFlag{Name: "seconds", EnvVars: []string{"SECONDS"}}, `could not parse "foobar" as int value from environment variable "SECONDS" for flag seconds: .*`},
@@ -233,15 +233,15 @@ func TestFlagsFromEnv(t *testing.T) {
233233
{"1", uint(1), &UintFlag{Name: "seconds", EnvVars: []string{"SECONDS"}}, ""},
234234
{"08", uint(8), &UintFlag{Name: "seconds", EnvVars: []string{"SECONDS"}, Base: 10}, ""},
235235
{"755", uint(493), &UintFlag{Name: "seconds", EnvVars: []string{"SECONDS"}, Base: 8}, ""},
236-
{"deadBEEF", uint(3735928559), &UintFlag{Name: "seconds", EnvVars: []string{"SECONDS"}, Base: 16}, ""},
236+
{"dBEEF", uint(900847), &UintFlag{Name: "seconds", EnvVars: []string{"SECONDS"}, Base: 16}, ""},
237237
{"08", 0, &UintFlag{Name: "seconds", EnvVars: []string{"SECONDS"}, Base: 0}, `could not parse "08" as uint value from environment variable "SECONDS" for flag seconds: .*`},
238238
{"1.2", 0, &UintFlag{Name: "seconds", EnvVars: []string{"SECONDS"}}, `could not parse "1.2" as uint value from environment variable "SECONDS" for flag seconds: .*`},
239239
{"foobar", 0, &UintFlag{Name: "seconds", EnvVars: []string{"SECONDS"}}, `could not parse "foobar" as uint value from environment variable "SECONDS" for flag seconds: .*`},
240240

241241
{"1", uint64(1), &Uint64Flag{Name: "seconds", EnvVars: []string{"SECONDS"}}, ""},
242242
{"08", uint64(8), &Uint64Flag{Name: "seconds", EnvVars: []string{"SECONDS"}, Base: 10}, ""},
243243
{"755", uint64(493), &Uint64Flag{Name: "seconds", EnvVars: []string{"SECONDS"}, Base: 8}, ""},
244-
{"deadBEEF", uint64(3735928559), &Uint64Flag{Name: "seconds", EnvVars: []string{"SECONDS"}, Base: 16}, ""},
244+
{"dBEEF", uint64(900847), &Uint64Flag{Name: "seconds", EnvVars: []string{"SECONDS"}, Base: 16}, ""},
245245
{"08", 0, &Uint64Flag{Name: "seconds", EnvVars: []string{"SECONDS"}, Base: 0}, `could not parse "08" as uint64 value from environment variable "SECONDS" for flag seconds: .*`},
246246
{"1.2", 0, &Uint64Flag{Name: "seconds", EnvVars: []string{"SECONDS"}}, `could not parse "1.2" as uint64 value from environment variable "SECONDS" for flag seconds: .*`},
247247
{"foobar", 0, &Uint64Flag{Name: "seconds", EnvVars: []string{"SECONDS"}}, `could not parse "foobar" as uint64 value from environment variable "SECONDS" for flag seconds: .*`},
@@ -1489,8 +1489,8 @@ var uintSliceFlagTests = []struct {
14891489
}{
14901490
{"heads", nil, NewUintSlice(), "--heads value [ --heads value ]\t"},
14911491
{"H", nil, NewUintSlice(), "-H value [ -H value ]\t"},
1492-
{"heads", []string{"H"}, NewUintSlice(uint(2), uint(17179869184)),
1493-
"--heads value, -H value [ --heads value, -H value ]\t(default: 2, 17179869184)"},
1492+
{"heads", []string{"H"}, NewUintSlice(uint(2), uint(79869184)),
1493+
"--heads value, -H value [ --heads value, -H value ]\t(default: 2, 79869184)"},
14941494
}
14951495

14961496
func TestUintSliceFlagHelpOutput(t *testing.T) {

0 commit comments

Comments
 (0)