Skip to content

Commit ed16803

Browse files
committed
refactor: remove ~45 low-value tests that can't meaningfully fail
Delete struct construction tests, constant assertions, type checks, and embedded data validations. Keep tests with real logic, I/O, and parsing behavior.
1 parent bd5f8a6 commit ed16803

12 files changed

Lines changed: 57 additions & 747 deletions

File tree

internal/brew/brew_command_test.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,3 @@ func TestDoctorDiagnose_UnknownWarnings(t *testing.T) {
203203
require.NoError(t, err)
204204
assert.Contains(t, suggestions, "Run: brew doctor (to see full diagnostic output)")
205205
}
206-
207-
func TestBrewInstallCmd_SetsNoAutoUpdate(t *testing.T) {
208-
cmd := brewInstallCmd("install", "git")
209-
assert.Equal(t, []string{"brew", "install", "git"}, cmd.Args)
210-
found := false
211-
for _, env := range cmd.Env {
212-
if env == "HOMEBREW_NO_AUTO_UPDATE=1" {
213-
found = true
214-
}
215-
}
216-
assert.True(t, found, "expected HOMEBREW_NO_AUTO_UPDATE=1 in env")
217-
}

internal/brew/brew_test.go

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"strings"
55
"testing"
66

7-
"github.com/openbootdotdev/openboot/internal/ui"
87
"github.com/stretchr/testify/assert"
98
)
109

@@ -187,51 +186,10 @@ func TestCheckDiskSpace(t *testing.T) {
187186
assert.Greater(t, gb, 0.0)
188187
}
189188

190-
func TestOutdatedPackageStruct(t *testing.T) {
191-
pkg := OutdatedPackage{
192-
Name: "git",
193-
Current: "2.40.0",
194-
Latest: "2.42.0",
195-
}
196-
assert.Equal(t, "git", pkg.Name)
197-
assert.Equal(t, "2.40.0", pkg.Current)
198-
assert.Equal(t, "2.42.0", pkg.Latest)
199-
}
200-
201-
func TestHandleFailedJobs_Empty(t *testing.T) {
202-
handleFailedJobs(nil)
203-
handleFailedJobs([]failedJob{})
204-
}
205-
206189
func TestHandleFailedJobs_WithFailures(t *testing.T) {
207190
failed := []failedJob{
208191
{installJob: installJob{name: "pkg1", isCask: false}, errMsg: "not found"},
209192
{installJob: installJob{name: "pkg2", isCask: true}, errMsg: ""},
210193
}
211194
handleFailedJobs(failed)
212195
}
213-
214-
func TestRunParallelInstallWithProgress_EmptyPkgs(t *testing.T) {
215-
result := runParallelInstallWithProgress(nil, nil)
216-
assert.Nil(t, result)
217-
}
218-
219-
func TestIsInstalled(t *testing.T) {
220-
result := IsInstalled()
221-
assert.IsType(t, true, result)
222-
}
223-
224-
func TestMaxWorkersConstant(t *testing.T) {
225-
assert.Equal(t, 1, maxWorkers)
226-
}
227-
228-
func TestPrintBrewOutput_Lines(t *testing.T) {
229-
p := ui.NewStickyProgress(1)
230-
printBrewOutput("line one\nline two\n line three \n", p)
231-
}
232-
233-
func TestPrintBrewOutput_Empty(t *testing.T) {
234-
p := ui.NewStickyProgress(1)
235-
printBrewOutput("", p)
236-
printBrewOutput(" \n ", p)
237-
}

internal/cli/sync_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -461,13 +461,6 @@ func TestPrintMissingExtraBothEmpty(t *testing.T) {
461461
assert.Empty(t, output)
462462
}
463463

464-
func TestPkgCategoryConstants(t *testing.T) {
465-
assert.Equal(t, pkgCategory("formulae"), categoryFormulae)
466-
assert.Equal(t, pkgCategory("casks"), categoryCasks)
467-
assert.Equal(t, pkgCategory("npm"), categoryNpm)
468-
assert.Equal(t, pkgCategory("taps"), categoryTaps)
469-
}
470-
471464
func TestBuildDryRunPlan(t *testing.T) {
472465
d := &syncpkg.SyncDiff{
473466
MissingFormulae: []string{"ripgrep", "fd"},

internal/config/packages_test.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,3 @@ func TestIsTapPackage(t *testing.T) {
161161
})
162162
}
163163
}
164-
165-
func TestGetAllPackageNames(t *testing.T) {
166-
names := GetAllPackageNames()
167-
168-
assert.Greater(t, len(names), 0)
169-
assert.Contains(t, names, "curl")
170-
assert.Contains(t, names, "node")
171-
assert.Contains(t, names, "typescript")
172-
assert.Contains(t, names, "visual-studio-code")
173-
}

internal/dotfiles/dotfiles_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ import (
1010
"github.com/stretchr/testify/require"
1111
)
1212

13-
func TestDefaultDotfilesURL(t *testing.T) {
14-
assert.Equal(t, "https://github.com/openbootdotdev/dotfiles", DefaultDotfilesURL)
15-
}
16-
1713
func TestGetDotfilesURL_Empty(t *testing.T) {
1814
t.Setenv("OPENBOOT_DOTFILES", "")
1915
url := GetDotfilesURL()

internal/installer/installer_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,6 @@ func TestStepMacOS_Silent_DryRun(t *testing.T) {
373373
assert.NoError(t, err)
374374
}
375375

376-
func TestInstallTimeConstants(t *testing.T) {
377-
assert.Equal(t, 15, estimatedSecondsPerFormula)
378-
assert.Equal(t, 30, estimatedSecondsPerCask)
379-
assert.Equal(t, 5, estimatedSecondsPerNpm)
380-
}
381-
382376
func TestInstallState_OnlySuccessfulPackagesMarked(t *testing.T) {
383377
tmpDir := t.TempDir()
384378
t.Setenv("HOME", tmpDir)

internal/macos/macos_test.go

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -88,32 +88,6 @@ func TestConfigure_DifferentTypes(t *testing.T) {
8888
assert.NoError(t, err)
8989
}
9090

91-
func TestDefaultPreferences_NotEmpty(t *testing.T) {
92-
assert.Greater(t, len(DefaultPreferences), 0)
93-
}
94-
95-
func TestDefaultPreferences_HasRequiredFields(t *testing.T) {
96-
for _, pref := range DefaultPreferences {
97-
assert.NotEmpty(t, pref.Domain, "Domain should not be empty")
98-
assert.NotEmpty(t, pref.Key, "Key should not be empty")
99-
assert.NotEmpty(t, pref.Type, "Type should not be empty")
100-
assert.NotEmpty(t, pref.Desc, "Description should not be empty")
101-
}
102-
}
103-
104-
func TestDefaultPreferences_ValidTypes(t *testing.T) {
105-
validTypes := map[string]bool{
106-
"bool": true,
107-
"int": true,
108-
"float": true,
109-
"string": true,
110-
}
111-
112-
for _, pref := range DefaultPreferences {
113-
assert.True(t, validTypes[pref.Type], "Type %s is not valid", pref.Type)
114-
}
115-
}
116-
11791
func TestCreateScreenshotsDir_DryRun(t *testing.T) {
11892
tmpHome := t.TempDir()
11993
t.Setenv("HOME", tmpHome)
@@ -159,33 +133,3 @@ func TestRestartAffectedApps_DryRun(t *testing.T) {
159133
// TestRestartAffectedApps_NoDryRun kills real system processes (Finder, Dock, SystemUIServer),
160134
// so it must only run with the integration build tag.
161135
// See test/integration/ for the integration-tagged version.
162-
163-
func TestDefaultPreferences_FinderPrefs(t *testing.T) {
164-
finderPrefs := []Preference{}
165-
for _, p := range DefaultPreferences {
166-
if p.Domain == "com.apple.finder" {
167-
finderPrefs = append(finderPrefs, p)
168-
}
169-
}
170-
assert.Greater(t, len(finderPrefs), 0, "Should have Finder preferences")
171-
}
172-
173-
func TestDefaultPreferences_DockPrefs(t *testing.T) {
174-
dockPrefs := []Preference{}
175-
for _, p := range DefaultPreferences {
176-
if p.Domain == "com.apple.dock" {
177-
dockPrefs = append(dockPrefs, p)
178-
}
179-
}
180-
assert.Greater(t, len(dockPrefs), 0, "Should have Dock preferences")
181-
}
182-
183-
func TestDefaultPreferences_ScreencapturePrefs(t *testing.T) {
184-
screencapturePrefs := []Preference{}
185-
for _, p := range DefaultPreferences {
186-
if p.Domain == "com.apple.screencapture" {
187-
screencapturePrefs = append(screencapturePrefs, p)
188-
}
189-
}
190-
assert.Greater(t, len(screencapturePrefs), 0, "Should have Screencapture preferences")
191-
}

internal/npm/npm_test.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,6 @@ func TestInstall_DryRun(t *testing.T) {
9696
assert.NoError(t, err)
9797
}
9898

99-
func TestInstall_DryRun_EmptyPackages(t *testing.T) {
100-
err := Install([]string{}, true)
101-
assert.NoError(t, err)
102-
}
103-
104-
func TestIsAvailable(t *testing.T) {
105-
result := IsAvailable()
106-
assert.IsType(t, true, result)
107-
}
108-
10999
func TestGetNodeVersion(t *testing.T) {
110100
if !IsAvailable() {
111101
t.Skip("node not available")

internal/snapshot/capture_test.go

Lines changed: 0 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -178,139 +178,6 @@ func TestSanitizePath(t *testing.T) {
178178
}
179179
}
180180

181-
// TestCaptureFormulae tests that CaptureFormulae returns a slice.
182-
func TestCaptureFormulae(t *testing.T) {
183-
formulae, err := CaptureFormulae()
184-
// Should either succeed or fail gracefully
185-
assert.True(t, err == nil || formulae != nil)
186-
assert.IsType(t, []string{}, formulae)
187-
}
188-
189-
// TestCaptureCasks tests that CaptureCasks returns a slice.
190-
func TestCaptureCasks(t *testing.T) {
191-
casks, err := CaptureCasks()
192-
// Should either succeed or fail gracefully
193-
assert.True(t, err == nil || casks != nil)
194-
assert.IsType(t, []string{}, casks)
195-
}
196-
197-
// TestCaptureTaps tests that CaptureTaps returns a slice.
198-
func TestCaptureTaps(t *testing.T) {
199-
taps, err := CaptureTaps()
200-
// Should either succeed or fail gracefully
201-
assert.True(t, err == nil || taps != nil)
202-
assert.IsType(t, []string{}, taps)
203-
}
204-
205-
// TestCaptureNpm tests that CaptureNpm returns a slice.
206-
func TestCaptureNpm(t *testing.T) {
207-
npm, err := CaptureNpm()
208-
// Should either succeed or fail gracefully
209-
assert.True(t, err == nil || npm != nil)
210-
assert.IsType(t, []string{}, npm)
211-
}
212-
213-
// TestCaptureShell tests that CaptureShell returns a ShellSnapshot.
214-
func TestCaptureShell(t *testing.T) {
215-
shell, err := CaptureShell()
216-
assert.NoError(t, err)
217-
assert.NotNil(t, shell)
218-
assert.IsType(t, &ShellSnapshot{}, shell)
219-
}
220-
221-
// TestCaptureGit tests that CaptureGit returns a GitSnapshot.
222-
func TestCaptureGit(t *testing.T) {
223-
git, err := CaptureGit()
224-
assert.NoError(t, err)
225-
assert.NotNil(t, git)
226-
assert.IsType(t, &GitSnapshot{}, git)
227-
}
228-
229-
// TestCaptureDevTools tests that CaptureDevTools returns a slice.
230-
func TestCaptureDevTools(t *testing.T) {
231-
tools, err := CaptureDevTools()
232-
assert.NoError(t, err)
233-
assert.NotNil(t, tools)
234-
assert.IsType(t, []DevTool{}, tools)
235-
}
236-
237-
// TestCaptureMacOSPrefs tests that CaptureMacOSPrefs returns a slice.
238-
func TestCaptureMacOSPrefs(t *testing.T) {
239-
prefs, err := CaptureMacOSPrefs()
240-
// Should either succeed or fail gracefully
241-
assert.True(t, err == nil || prefs != nil)
242-
assert.IsType(t, []MacOSPref{}, prefs)
243-
}
244-
245-
// TestParseLines_EdgeCases tests parseLines with edge cases.
246-
func TestParseLines_EdgeCases(t *testing.T) {
247-
tests := []struct {
248-
name string
249-
input string
250-
minItems int
251-
maxItems int
252-
}{
253-
{
254-
name: "only whitespace",
255-
input: " \n \n ",
256-
minItems: 0,
257-
maxItems: 0,
258-
},
259-
{
260-
name: "mixed whitespace",
261-
input: " \t \n \t \n \t ",
262-
minItems: 0,
263-
maxItems: 0,
264-
},
265-
{
266-
name: "single item with spaces",
267-
input: " git ",
268-
minItems: 1,
269-
maxItems: 1,
270-
},
271-
}
272-
273-
for _, tt := range tests {
274-
t.Run(tt.name, func(t *testing.T) {
275-
result := parseLines(tt.input)
276-
assert.GreaterOrEqual(t, len(result), tt.minItems)
277-
assert.LessOrEqual(t, len(result), tt.maxItems)
278-
})
279-
}
280-
}
281-
282-
// TestParseVersion_EdgeCases tests parseVersion with edge cases.
283-
func TestParseVersion_EdgeCases(t *testing.T) {
284-
tests := []struct {
285-
name string
286-
toolName string
287-
output string
288-
}{
289-
{
290-
name: "empty output",
291-
toolName: "go",
292-
output: "",
293-
},
294-
{
295-
name: "whitespace only",
296-
toolName: "node",
297-
output: " ",
298-
},
299-
{
300-
name: "malformed output",
301-
toolName: "go",
302-
output: "invalid output format",
303-
},
304-
}
305-
306-
for _, tt := range tests {
307-
t.Run(tt.name, func(t *testing.T) {
308-
result := parseVersion(tt.toolName, tt.output)
309-
// Should not panic and return a string
310-
assert.IsType(t, "", result)
311-
})
312-
}
313-
}
314181

315182
func TestCaptureWithProgress_HealthTracksFailedSteps(t *testing.T) {
316183
steps := []captureStep{

0 commit comments

Comments
 (0)