style(setup): satisfy govet shadow + thelper lints

Two lint findings flagged by golangci-lint:

  - telnet_probe.go:90 — t.Dial()'s local err shadowed the outer
    url.Parse error (govet shadow). Renamed the inner one to
    dialErr.
  - migration_summary_telnet_test.go:20 — telnetSummaryEnv didn't
    call t.Helper(), so test failures pointed at the helper rather
    than the calling test (thelper). Now mirrors the t.Helper() in
    telnetSummaryEnvWithInfo.

No behaviour change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tobias Gesellchen
2026-05-11 00:37:11 +02:00
co-authored by Claude Opus 4.7
parent 95e76b52ad
commit 6617c22967
4 changed files with 13 additions and 6 deletions
@@ -18,6 +18,7 @@ import (
// so the live-info call works; the SSH and telnet clients ignore the addr
// and return whatever the fakes are scripted to return.
func telnetSummaryEnv(t *testing.T, ssh *mockSSH, ft *fakeTelnet) (*Manager, string, func()) {
t.Helper()
return telnetSummaryEnvWithInfo(t, ssh, ft, `<info deviceID="123"><name>Test</name></info>`)
}
+1
View File
@@ -274,6 +274,7 @@ func (m *Manager) GetMigrationSummary(deviceIP, targetURL, proxyURL string, opti
go func() {
var local MigrationSummary
m.telnetPreflight(&local, deviceIP)
telnetCh <- local
}()
+7 -2
View File
@@ -87,8 +87,8 @@ func (m *Manager) RunTelnetRoundTripProbe(deviceIP, targetURL string, registrar
var logs strings.Builder
t := m.NewTelnet(deviceIP)
if err := t.Dial(); err != nil {
return nil, fmt.Errorf("telnet dial %s:17000 failed: %w", deviceIP, err)
if dialErr := t.Dial(); dialErr != nil {
return nil, fmt.Errorf("telnet dial %s:17000 failed: %w", deviceIP, dialErr)
}
defer func() { _ = t.Close() }()
@@ -147,10 +147,12 @@ func (m *Manager) RunTelnetRoundTripProbe(deviceIP, targetURL string, registrar
restoreCmd := "sys configuration swUpdateUrl " + originalURL
if rresp, rerr := t.SendCommand(restoreCmd); rerr == nil && !isCommandNotFound(rresp) {
result.Restored = true
fmt.Fprintf(&logs, "→ %s (restored)\n%s\n", restoreCmd, strings.TrimRight(rresp, "\r\n"))
} else if rerr != nil {
fmt.Fprintf(&logs, "Restore failed: %v (envswitch persistence will heal on next reboot)\n", rerr)
}
result.Logs = logs.String()
}()
@@ -158,6 +160,7 @@ func (m *Manager) RunTelnetRoundTripProbe(deviceIP, targetURL string, registrar
// HTTP call is fire-and-forget — we don't need its response, only
// that the device fans out to the probe URL we just set.
swCheckURL := fmt.Sprintf("http://%s:8090/swUpdateCheck", deviceIP)
go func() {
if m.HTTPGet == nil {
return
@@ -177,9 +180,11 @@ func (m *Manager) RunTelnetRoundTripProbe(deviceIP, targetURL string, registrar
select {
case <-probeCh:
result.Reached = true
fmt.Fprintf(&logs, "Probe inbound observed after %v\n", time.Since(start))
case <-time.After(timeout):
result.Reached = false
fmt.Fprintf(&logs, "Probe timed out after %v\n", timeout)
}
+4 -4
View File
@@ -115,10 +115,10 @@ func TestMigrateViaTelnet_SoundcorkMargeSuffixPropagatesToEnvswitch(t *testing.T
// Build a happy-path responder that matches the *new* command set.
resp := map[string]string{
"sys configuration bmxRegistryUrl " + urls.BmxRegistry: "OK\n",
"sys configuration statsServerUrl " + urls.Stats: "OK\n",
"sys configuration margeServerUrl " + urls.Marge: "OK\n",
"sys configuration swUpdateUrl " + urls.SwUpdate: "OK\n",
"sys configuration bmxRegistryUrl " + urls.BmxRegistry: "OK\n",
"sys configuration statsServerUrl " + urls.Stats: "OK\n",
"sys configuration margeServerUrl " + urls.Marge: "OK\n",
"sys configuration swUpdateUrl " + urls.SwUpdate: "OK\n",
"envswitch boseurls set " + urls.Marge + " " + urls.SwUpdate: "OK\n",
"getpdo CurrentSystemConfiguration": "margeServerUrl=" + urls.Marge + "\n",
}