Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit e064c47

Browse files
committed
fixup! internal/cmd/update.go: handle windows-specific behaviours
1 parent 21dd836 commit e064c47

File tree

2 files changed

+31
-29
lines changed

2 files changed

+31
-29
lines changed

internal/cmd/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func (u *updater) Run(ctx context.Context, force bool, coderURLArg string, versi
218218

219219
func (u *updater) doUpdate(ctx context.Context, updatedCoderBinaryPath string) error {
220220
var err error
221-
// TODO(cian): on Windows, we must do two things differnetly:
221+
// TODO(cian): on Windows, we must do two things differently:
222222
// 1) Calling the updated binary fails due to the xterminal.MakeOutputRaw call in main; skipping this check on Windows.
223223
// 2) We must rename the currently running binary before renaming the new binary
224224
if u.osF() == goosWindows {

internal/cmd/update_test.go

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -71,34 +71,36 @@ func Test_updater_run(t *testing.T) {
7171
}
7272

7373
run := func(t *testing.T, name string, fn func(t *testing.T, p *params)) {
74-
t.Logf("running %s", name)
75-
ctx := context.Background()
76-
fakefs := afero.NewMemMapFs()
77-
execer := newFakeExecer(t)
78-
execer.M["brew --prefix"] = fakeExecerResult{[]byte{}, os.ErrNotExist}
79-
params := &params{
80-
// This must be overridden inside run()
81-
ConfirmF: func(string) (string, error) {
82-
t.Errorf("unhandled ConfirmF")
83-
t.FailNow()
84-
return "", nil
85-
},
86-
Execer: execer,
87-
Ctx: ctx,
88-
ExecutablePath: fakeExePathLinux,
89-
Fakefs: fakefs,
90-
HTTPClient: newFakeGetter(t),
91-
// Default to GOOS=linux
92-
OsF: func() string { return goosLinux },
93-
// This must be overridden inside run()
94-
VersionF: func() string {
95-
t.Errorf("unhandled VersionF")
96-
t.FailNow()
97-
return ""
98-
},
99-
}
100-
101-
fn(t, params)
74+
t.Run(name, func(t *testing.T) {
75+
t.Logf("running %s", name)
76+
ctx := context.Background()
77+
fakefs := afero.NewMemMapFs()
78+
execer := newFakeExecer(t)
79+
execer.M["brew --prefix"] = fakeExecerResult{[]byte{}, os.ErrNotExist}
80+
params := &params{
81+
// This must be overridden inside run()
82+
ConfirmF: func(string) (string, error) {
83+
t.Errorf("unhandled ConfirmF")
84+
t.FailNow()
85+
return "", nil
86+
},
87+
Execer: execer,
88+
Ctx: ctx,
89+
ExecutablePath: fakeExePathLinux,
90+
Fakefs: fakefs,
91+
HTTPClient: newFakeGetter(t),
92+
// Default to GOOS=linux
93+
OsF: func() string { return goosLinux },
94+
// This must be overridden inside run()
95+
VersionF: func() string {
96+
t.Errorf("unhandled VersionF")
97+
t.FailNow()
98+
return ""
99+
},
100+
}
101+
102+
fn(t, params)
103+
})
102104
}
103105

104106
run(t, "update coder - noop", func(t *testing.T, p *params) {

0 commit comments

Comments
 (0)