fix: resolve lint issues from reconnect change

Remove unused osExit var and os import, convert if/else chain to
tagged switch per staticcheck QF1003.
This commit is contained in:
Graham McIntire 2026-03-23 12:54:32 -05:00
parent fcac48e4e5
commit 3d98105853
No known key found for this signature in database
2 changed files with 4 additions and 5 deletions

View file

@ -8,7 +8,6 @@ import (
"fmt" "fmt"
"log/slog" "log/slog"
"math/rand/v2" "math/rand/v2"
"os"
"runtime" "runtime"
"strconv" "strconv"
"strings" "strings"
@ -20,7 +19,6 @@ import (
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
var osExit = os.Exit
var doSelfUpdate = selfUpdate var doSelfUpdate = selfUpdate
var errRestartRequested = fmt.Errorf("restart requested") var errRestartRequested = fmt.Errorf("restart requested")

View file

@ -1075,14 +1075,15 @@ func TestRunAgentReconnectOnError(t *testing.T) {
key := extractWSKey(string(buf[:n])) key := extractWSKey(string(buf[:n]))
accept := computeAcceptKey(key) accept := computeAcceptKey(key)
if count == 1 { switch count {
case 1:
// First connection: upgrade then close immediately (triggers error reconnect) // First connection: upgrade then close immediately (triggers error reconnect)
resp := "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: " + accept + "\r\n\r\n" resp := "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: " + accept + "\r\n\r\n"
_, _ = conn.Write([]byte(resp)) _, _ = conn.Write([]byte(resp))
frameBuf := make([]byte, 4096) frameBuf := make([]byte, 4096)
_, _ = conn.Read(frameBuf) _, _ = conn.Read(frameBuf)
_ = conn.Close() _ = conn.Close()
} else if count == 2 { case 2:
// Second connection: proper session with restart (triggers restart reconnect) // Second connection: proper session with restart (triggers restart reconnect)
resp := "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: " + accept + "\r\n\r\n" resp := "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: " + accept + "\r\n\r\n"
_, _ = conn.Write([]byte(resp)) _, _ = conn.Write([]byte(resp))
@ -1104,7 +1105,7 @@ func TestRunAgentReconnectOnError(t *testing.T) {
_, _ = conn.Write(makeTextFrame(restart)) _, _ = conn.Write(makeTextFrame(restart))
time.Sleep(time.Second) time.Sleep(time.Second)
_ = conn.Close() _ = conn.Close()
} else { default:
// Third connection: agent successfully reconnected after restart // Third connection: agent successfully reconnected after restart
_ = conn.Close() _ = conn.Close()
} }