all: fix golangci-lint issues (#3064)
This commit is contained in:
parent
bfb6fd80df
commit
ce580f8245
131 changed files with 3131 additions and 1560 deletions
|
|
@ -86,7 +86,8 @@ func TestYesNo(t *testing.T) {
|
|||
// Write test input
|
||||
go func() {
|
||||
defer w.Close()
|
||||
w.WriteString(tt.input)
|
||||
|
||||
_, _ = w.WriteString(tt.input)
|
||||
}()
|
||||
|
||||
// Call the function
|
||||
|
|
@ -95,6 +96,7 @@ func TestYesNo(t *testing.T) {
|
|||
// Restore stdin and stderr
|
||||
os.Stdin = oldStdin
|
||||
os.Stderr = oldStderr
|
||||
|
||||
stderrW.Close()
|
||||
|
||||
// Check the result
|
||||
|
|
@ -104,10 +106,12 @@ func TestYesNo(t *testing.T) {
|
|||
|
||||
// Check that the prompt was written to stderr
|
||||
var stderrBuf bytes.Buffer
|
||||
io.Copy(&stderrBuf, stderrR)
|
||||
|
||||
_, _ = io.Copy(&stderrBuf, stderrR)
|
||||
stderrR.Close()
|
||||
|
||||
expectedPrompt := "Test question [y/n] "
|
||||
|
||||
actualPrompt := stderrBuf.String()
|
||||
if actualPrompt != expectedPrompt {
|
||||
t.Errorf("Expected prompt %q, got %q", expectedPrompt, actualPrompt)
|
||||
|
|
@ -130,7 +134,8 @@ func TestYesNoPromptMessage(t *testing.T) {
|
|||
// Write test input
|
||||
go func() {
|
||||
defer w.Close()
|
||||
w.WriteString("n\n")
|
||||
|
||||
_, _ = w.WriteString("n\n")
|
||||
}()
|
||||
|
||||
// Call the function with a custom message
|
||||
|
|
@ -140,14 +145,17 @@ func TestYesNoPromptMessage(t *testing.T) {
|
|||
// Restore stdin and stderr
|
||||
os.Stdin = oldStdin
|
||||
os.Stderr = oldStderr
|
||||
|
||||
stderrW.Close()
|
||||
|
||||
// Check that the custom message was included in the prompt
|
||||
var stderrBuf bytes.Buffer
|
||||
io.Copy(&stderrBuf, stderrR)
|
||||
|
||||
_, _ = io.Copy(&stderrBuf, stderrR)
|
||||
stderrR.Close()
|
||||
|
||||
expectedPrompt := customMessage + " [y/n] "
|
||||
|
||||
actualPrompt := stderrBuf.String()
|
||||
if actualPrompt != expectedPrompt {
|
||||
t.Errorf("Expected prompt %q, got %q", expectedPrompt, actualPrompt)
|
||||
|
|
@ -186,7 +194,8 @@ func TestYesNoCaseInsensitive(t *testing.T) {
|
|||
// Write test input
|
||||
go func() {
|
||||
defer w.Close()
|
||||
w.WriteString(tc.input)
|
||||
|
||||
_, _ = w.WriteString(tc.input)
|
||||
}()
|
||||
|
||||
// Call the function
|
||||
|
|
@ -195,10 +204,11 @@ func TestYesNoCaseInsensitive(t *testing.T) {
|
|||
// Restore stdin and stderr
|
||||
os.Stdin = oldStdin
|
||||
os.Stderr = oldStderr
|
||||
|
||||
stderrW.Close()
|
||||
|
||||
// Drain stderr
|
||||
io.Copy(io.Discard, stderrR)
|
||||
_, _ = io.Copy(io.Discard, stderrR)
|
||||
stderrR.Close()
|
||||
|
||||
if result != tc.expected {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue