detached 210b482

fix: address review feedback — testify assertions and dead code removal

- Replace manual t.Fatalf checks with testify/require in resolver tests
- Remove dead ctx.Err() check in finalizePreviousContainer — the caller
  now passes context.WithoutCancel so this branch was unreachable
commit
210b4824f0c0995b30cff90575347a6f139c67ee
author
brice · · 2026-03-19 04:03 UTC
parent
8547d4d
signature
unsigned
2 files · +12 -26
M internal/adapters/in/cli/controlplane_resolver_test.go +12 -20
@@ -4,6 +4,8 @@ import (
44 "os"
55 "path/filepath"
66 "testing"
7+
8+ "github.com/stretchr/testify/require"
79 )
810
911 func TestResolveControlPlane_LocalAllowedWhenAuthEnabled(t *testing.T) {
@@ -31,18 +33,13 @@ data_dir = "`+filepath.Join(tmpDir, "data")+`"
3133 enabled = true
3234 secrets_backend = "unsafe"
3335 `), 0o600)
34- if err != nil {
35- t.Fatalf("failed to write config: %v", err)
36- }
36+ require.NoError(t, err)
3737
3838 handle, err := resolveControlPlane(configPath)
39- if err != nil {
40- t.Fatalf("expected local control-plane handle, got error: %v", err)
41- }
42- if handle == nil || handle.plane == nil {
43- t.Fatalf("expected non-nil local control-plane handle")
44- }
45- handle.close()
39+ require.NoError(t, err)
40+ require.NotNil(t, handle)
41+ require.NotNil(t, handle.plane)
42+ defer handle.close()
4643 }
4744
4845 func TestResolveControlPlane_LocalAllowedWhenAuthDisabled(t *testing.T) {
@@ -70,16 +67,11 @@ data_dir = "`+filepath.Join(tmpDir, "data")+`"
7067 enabled = false
7168 secrets_backend = "unsafe"
7269 `), 0o600)
73- if err != nil {
74- t.Fatalf("failed to write config: %v", err)
75- }
70+ require.NoError(t, err)
7671
7772 handle, err := resolveControlPlane(configPath)
78- if err != nil {
79- t.Fatalf("expected local control-plane handle, got error: %v", err)
80- }
81- if handle == nil || handle.plane == nil {
82- t.Fatalf("expected non-nil local control-plane handle")
83- }
84- handle.close()
73+ require.NoError(t, err)
74+ require.NotNil(t, handle)
75+ require.NotNil(t, handle.plane)
76+ defer handle.close()
8577 }
@@ -4,6 +4,8 @@ import (
4 "os"4 "os"
5 "path/filepath"5 "path/filepath"
6 "testing"6 "testing"
7+
8+ "github.com/stretchr/testify/require"
7 )9 )
8 10
9 func TestResolveControlPlane_LocalAllowedWhenAuthEnabled(t *testing.T) {11 func TestResolveControlPlane_LocalAllowedWhenAuthEnabled(t *testing.T) {
@@ -31,18 +33,13 @@ data_dir = "`+filepath.Join(tmpDir, "data")+`"
31 enabled = true33 enabled = true
32 secrets_backend = "unsafe"34 secrets_backend = "unsafe"
33 `), 0o600)35 `), 0o600)
34- if err != nil {36+ require.NoError(t, err)
35- t.Fatalf("failed to write config: %v", err)
36- }
37 37
38 handle, err := resolveControlPlane(configPath)38 handle, err := resolveControlPlane(configPath)
39- if err != nil {39+ require.NoError(t, err)
40- t.Fatalf("expected local control-plane handle, got error: %v", err)40+ require.NotNil(t, handle)
41- }41+ require.NotNil(t, handle.plane)
42- if handle == nil || handle.plane == nil {42+ defer handle.close()
43- t.Fatalf("expected non-nil local control-plane handle")
44- }
45- handle.close()
46 }43 }
47 44
48 func TestResolveControlPlane_LocalAllowedWhenAuthDisabled(t *testing.T) {45 func TestResolveControlPlane_LocalAllowedWhenAuthDisabled(t *testing.T) {
@@ -70,16 +67,11 @@ data_dir = "`+filepath.Join(tmpDir, "data")+`"
70 enabled = false67 enabled = false
71 secrets_backend = "unsafe"68 secrets_backend = "unsafe"
72 `), 0o600)69 `), 0o600)
73- if err != nil {70+ require.NoError(t, err)
74- t.Fatalf("failed to write config: %v", err)
75- }
76 71
77 handle, err := resolveControlPlane(configPath)72 handle, err := resolveControlPlane(configPath)
78- if err != nil {73+ require.NoError(t, err)
79- t.Fatalf("expected local control-plane handle, got error: %v", err)74+ require.NotNil(t, handle)
80- }75+ require.NotNil(t, handle.plane)
81- if handle == nil || handle.plane == nil {76+ defer handle.close()
82- t.Fatalf("expected non-nil local control-plane handle")
83- }
84- handle.close()
85 }77 }
M internal/usecase/container/service.go +0 -6
@@ -743,17 +743,11 @@ func (s *Service) finalizePreviousContainer(ctx context.Context, domainName stri
743743 if !hasExisting {
744744 return
745745 }
746- log := zerowrap.FromCtx(ctx)
747746
748747 if invalidated {
749748 s.waitForDrain(ctx, existing.ID)
750749 }
751750
752- if err := ctx.Err(); err != nil {
753- log.Debug().Err(err).Str("domain", domainName).Str("new_container_id", newContainerID).Msg("skipping old container cleanup due to canceled context")
754- return
755- }
756-
757751 s.cleanupOldContainer(ctx, existing, newContainerID, domainName)
758752 }
759753
@@ -743,17 +743,11 @@ func (s *Service) finalizePreviousContainer(ctx context.Context, domainName stri
743 if !hasExisting {743 if !hasExisting {
744 return744 return
745 }745 }
746- log := zerowrap.FromCtx(ctx)
747 746
748 if invalidated {747 if invalidated {
749 s.waitForDrain(ctx, existing.ID)748 s.waitForDrain(ctx, existing.ID)
750 }749 }
751 750
752- if err := ctx.Err(); err != nil {
753- log.Debug().Err(err).Str("domain", domainName).Str("new_container_id", newContainerID).Msg("skipping old container cleanup due to canceled context")
754- return
755- }
756-
757 s.cleanupOldContainer(ctx, existing, newContainerID, domainName)751 s.cleanupOldContainer(ctx, existing, newContainerID, domainName)
758 }752 }
759 753

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close