Skip to content

Commit a2c00de

Browse files
committed
Refactor test files to improve readability and maintainability: Remove unnecessary blank lines in various test files across the project, enhancing code clarity and consistency. This change contributes to better organization and easier navigation of the test suite.
1 parent 3b874d3 commit a2c00de

File tree

18 files changed

+250
-248
lines changed

18 files changed

+250
-248
lines changed

cmd/quiver/assets/icon_utils_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,50 +105,50 @@ func TestEmbeddedIcons(t *testing.T) {
105105

106106
func TestIconManager_GetIconPath(t *testing.T) {
107107
manager := NewIconManager()
108-
108+
109109
// Initially should be empty
110110
if manager.GetIconPath() != "" {
111111
t.Error("Icon path should be empty initially")
112112
}
113-
113+
114114
// Save icon to temp and check path
115115
tempFile, err := manager.SaveIconToTemp()
116116
if err != nil {
117117
t.Fatalf("Failed to save icon to temp: %v", err)
118118
}
119119
defer manager.Cleanup()
120-
120+
121121
if manager.GetIconPath() != tempFile {
122122
t.Error("Icon path should match saved temp file")
123123
}
124124
}
125125

126126
func TestIconManager_Cleanup(t *testing.T) {
127127
manager := NewIconManager()
128-
128+
129129
// Test cleanup when no icon is saved
130130
err := manager.Cleanup()
131131
if err != nil {
132132
t.Errorf("Cleanup should not error when no icon is saved: %v", err)
133133
}
134-
134+
135135
// Save icon and test cleanup
136136
tempFile, err := manager.SaveIconToTemp()
137137
if err != nil {
138138
t.Fatalf("Failed to save icon to temp: %v", err)
139139
}
140-
140+
141141
// Verify file exists
142142
if _, err := os.Stat(tempFile); os.IsNotExist(err) {
143143
t.Error("Icon file should exist before cleanup")
144144
}
145-
145+
146146
// Cleanup and verify file is removed
147147
err = manager.Cleanup()
148148
if err != nil {
149149
t.Errorf("Cleanup should not error: %v", err)
150150
}
151-
151+
152152
// Verify file is removed
153153
if _, err := os.Stat(tempFile); !os.IsNotExist(err) {
154154
t.Error("Icon file should be removed after cleanup")
@@ -157,19 +157,19 @@ func TestIconManager_Cleanup(t *testing.T) {
157157

158158
func TestIconManager_PlatformSpecific(t *testing.T) {
159159
manager := NewIconManager()
160-
160+
161161
// Test GetIconForPlatform for all platforms
162162
iconData := manager.GetIconForPlatform()
163163
if len(iconData) == 0 {
164164
t.Error("Icon data should not be empty for any platform")
165165
}
166-
166+
167167
// Test GetIconSize for all platforms
168168
sizeData := manager.GetIconSize()
169169
if len(sizeData) == 0 {
170170
t.Error("Icon size data should not be empty for any platform")
171171
}
172-
172+
173173
// Test platform-specific behavior
174174
switch runtime.GOOS {
175175
case "windows":
@@ -212,25 +212,25 @@ func TestIconManager_PlatformSpecific(t *testing.T) {
212212

213213
func TestIconManager_MultipleOperations(t *testing.T) {
214214
manager := NewIconManager()
215-
215+
216216
// Test multiple save operations
217217
tempFile1, err := manager.SaveIconToTemp()
218218
if err != nil {
219219
t.Fatalf("First save failed: %v", err)
220220
}
221221
defer manager.Cleanup()
222-
222+
223223
// Save again (should overwrite)
224224
tempFile2, err := manager.SaveIconToTemp()
225225
if err != nil {
226226
t.Fatalf("Second save failed: %v", err)
227227
}
228-
228+
229229
// Paths should be the same
230230
if tempFile1 != tempFile2 {
231231
t.Error("Icon path should remain the same on multiple saves")
232232
}
233-
233+
234234
// Test that file exists and has content
235235
if _, err := os.Stat(tempFile2); os.IsNotExist(err) {
236236
t.Error("Icon file should exist after second save")

cmd/quiver/ui/model_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,9 +695,9 @@ func TestModel_ShowQueryError_Comprehensive(t *testing.T) {
695695

696696
// Test different query error scenarios
697697
testCases := []struct {
698-
query string
699-
status int
700-
error string
698+
query string
699+
status int
700+
error string
701701
}{
702702
{"test query", 404, "not found"},
703703
{"error query", 500, "internal server error"},
@@ -838,7 +838,7 @@ func TestModel_SetStatus_Comprehensive(t *testing.T) {
838838

839839
// Test different status scenarios
840840
statuses := []struct {
841-
message string
841+
message string
842842
duration time.Duration
843843
}{
844844
{"Normal status", 2 * time.Second},

cmd/quiver/ui/service_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func TestRunUIModelState(t *testing.T) {
178178
func TestRunUIComprehensive(t *testing.T) {
179179
// Test comprehensive RunUI functionality
180180
w := watcher.NewWatcherService()
181-
181+
182182
// Test that we can create a model (what RunUI does)
183183
model := NewModel(w)
184184
if model == nil {
@@ -242,7 +242,7 @@ func TestRunUIWithDifferentWatcherStates(t *testing.T) {
242242

243243
func TestRunUIErrorScenarios(t *testing.T) {
244244
// Test various error scenarios that RunUI might handle
245-
245+
246246
// Test with nil watcher
247247
defer func() {
248248
if r := recover(); r != nil {
@@ -273,7 +273,7 @@ func TestRunUIModelLifecycle(t *testing.T) {
273273

274274
// Test that model can handle updates (what RunUI does)
275275
msg := tea.WindowSizeMsg{Width: 100, Height: 50}
276-
updatedModel, cmd := model.Update(msg)
276+
updatedModel, _ := model.Update(msg)
277277
if updatedModel == nil {
278278
t.Error("Update should return a model")
279279
}
@@ -287,7 +287,7 @@ func TestRunUIModelLifecycle(t *testing.T) {
287287
// Test cleanup (what RunUI does on exit)
288288
if model.cancel != nil {
289289
model.cancel()
290-
290+
291291
// Verify context is cancelled
292292
select {
293293
case <-model.ctx.Done():

internal/api/api_test.go

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ import (
1414
func TestAPI_Run(t *testing.T) {
1515
// Create a mock watcher
1616
watcherService := watcher.NewWatcherService()
17-
17+
1818
// Create mock usecases
1919
mockUsecases := &usecases.Usecases{}
20-
20+
2121
// Create API instance
2222
api := NewAPI(watcherService, mockUsecases)
23-
23+
2424
// Test that Run method doesn't panic
2525
// Note: This will actually start a server, so we test it in a goroutine
2626
// and then we can't easily test the full functionality without mocking
@@ -30,7 +30,7 @@ func TestAPI_Run(t *testing.T) {
3030
t.Errorf("API.Run() panicked: %v", r)
3131
}
3232
}()
33-
33+
3434
// The Run method will block, so we can't test it fully without mocking
3535
// But we can test that the method exists and the API struct is properly initialized
3636
if api.router == nil {
@@ -47,40 +47,40 @@ func TestAPI_Run(t *testing.T) {
4747
func TestAPI_SetupMiddleware(t *testing.T) {
4848
// Create a mock watcher
4949
watcherService := watcher.NewWatcherService()
50-
50+
5151
// Create mock usecases
5252
mockUsecases := &usecases.Usecases{}
53-
53+
5454
// Create API instance
5555
api := NewAPI(watcherService, mockUsecases)
56-
56+
5757
// Test that SetupMiddleware doesn't panic
5858
defer func() {
5959
if r := recover(); r != nil {
6060
t.Errorf("API.SetupMiddleware() panicked: %v", r)
6161
}
6262
}()
63-
63+
6464
api.SetupMiddleware()
6565
}
6666

6767
func TestAPI_SetupRoutes(t *testing.T) {
6868
// Create a mock watcher
6969
watcherService := watcher.NewWatcherService()
70-
70+
7171
// Create mock usecases
7272
mockUsecases := &usecases.Usecases{}
73-
73+
7474
// Create API instance
7575
api := NewAPI(watcherService, mockUsecases)
76-
76+
7777
// Test that SetupRoutes doesn't panic
7878
defer func() {
7979
if r := recover(); r != nil {
8080
t.Errorf("API.SetupRoutes() panicked: %v", r)
8181
}
8282
}()
83-
83+
8484
api.SetupRoutes()
8585
}
8686

@@ -127,15 +127,15 @@ func TestAPI_Run_ActualExecution(t *testing.T) {
127127
// Test that Run method can be called without panicking
128128
// We'll run it in a goroutine and then stop it quickly
129129
done := make(chan bool)
130-
130+
131131
go func() {
132132
defer func() {
133133
if r := recover(); r != nil {
134134
t.Errorf("API.Run() panicked: %v", r)
135135
}
136136
done <- true
137137
}()
138-
138+
139139
// This will block, but we'll stop it quickly
140140
api.Run()
141141
}()
@@ -223,9 +223,8 @@ func TestAPI_NewAPI_WithDifferentWatcherConfigs(t *testing.T) {
223223

224224
// Test that we can get the watcher level
225225
level := watcherService.GetLevel()
226-
if level < 0 {
227-
t.Error("Expected watcher level to be valid")
228-
}
226+
// level is a uint32, so it can't be negative, but we can test it's accessible
227+
_ = level
229228
}
230229

231230
func TestAPI_NewAPI_WithDifferentUsecases(t *testing.T) {
@@ -292,17 +291,17 @@ func TestAPI_NewAPI_WithDifferentWatcherLevels(t *testing.T) {
292291

293292
// Test with different levels to trigger different branches
294293
levels := []int{0, 1, 2, 3, 4, 5, 6, 7, 8}
295-
294+
296295
for _, level := range levels {
297296
// Set the watcher level (if possible)
298297
watcherService.SetLevel(logrus.Level(level))
299-
298+
300299
// Create API with this level
301300
api := NewAPI(watcherService, mockUsecases)
302301
if api == nil {
303302
t.Fatalf("Expected API to be created with level %d", level)
304303
}
305-
304+
306305
// Test that the API is properly initialized
307306
if api.router == nil {
308307
t.Errorf("Expected router to be initialized with level %d", level)
@@ -324,7 +323,7 @@ func TestAPI_NewAPI_ComprehensiveBranches(t *testing.T) {
324323
// Test that we can get the watcher level and config
325324
level := watcherService.GetLevel()
326325
config := watcherService.GetConfig()
327-
326+
328327
// Test different level scenarios
329328
if level <= 4 {
330329
// This should trigger debug mode
@@ -333,10 +332,10 @@ func TestAPI_NewAPI_ComprehensiveBranches(t *testing.T) {
333332
// This should trigger release mode
334333
_ = level
335334
}
336-
335+
337336
// Test that config is accessible
338337
_ = config
339-
338+
340339
// Test that the API is properly initialized
341340
if api.router == nil {
342341
t.Error("Expected router to be initialized")
@@ -383,4 +382,4 @@ func TestAPI_SetupRoutes_Comprehensive(t *testing.T) {
383382
if api.router == nil {
384383
t.Error("Expected router to be initialized")
385384
}
386-
}
385+
}

internal/api/v1/controllers/arrows/routes_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ func TestSetupRoutes(t *testing.T) {
1111
// Create a test router
1212
router := gin.New()
1313
routerGroup := router.Group("/api/v1")
14-
14+
1515
// Create a mock usecase
1616
usecases := &usecase.ArrowsUsecase{}
17-
17+
1818
// Test that SetupRoutes doesn't panic
1919
defer func() {
2020
if r := recover(); r != nil {
2121
t.Errorf("SetupRoutes() panicked: %v", r)
2222
}
2323
}()
24-
24+
2525
// Call SetupRoutes
2626
SetupRoutes(routerGroup, usecases)
27-
27+
2828
// The function is currently empty, so we just test it doesn't panic
2929
// and can be called with valid parameters
3030
}
@@ -33,14 +33,14 @@ func TestSetupRoutesWithNilUsecase(t *testing.T) {
3333
// Create a test router
3434
router := gin.New()
3535
routerGroup := router.Group("/api/v1")
36-
36+
3737
// Test with nil usecase
3838
defer func() {
3939
if r := recover(); r != nil {
4040
t.Errorf("SetupRoutes() panicked with nil usecase: %v", r)
4141
}
4242
}()
43-
43+
4444
SetupRoutes(routerGroup, nil)
4545
}
4646

@@ -51,7 +51,7 @@ func TestSetupRoutesWithNilRouter(t *testing.T) {
5151
t.Errorf("SetupRoutes() panicked with nil router: %v", r)
5252
}
5353
}()
54-
54+
5555
usecases := &usecase.ArrowsUsecase{}
5656
SetupRoutes(nil, usecases)
5757
}
@@ -95,7 +95,7 @@ func TestSetupRoutes_EdgeCases(t *testing.T) {
9595
// Test with different router groups
9696
group1 := router.Group("/test1")
9797
group2 := router.Group("/test2")
98-
98+
9999
SetupRoutes(group1, usecases)
100100
SetupRoutes(group2, usecases)
101101

@@ -106,4 +106,4 @@ func TestSetupRoutes_EdgeCases(t *testing.T) {
106106
if group2 == nil {
107107
t.Error("Expected group2 to be valid")
108108
}
109-
}
109+
}

0 commit comments

Comments
 (0)