Skip to content

Commit f80fc48

Browse files
committed
mock the systray for tests
1 parent 6bd1a21 commit f80fc48

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

cmd/goose/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ type App struct {
8787
enableAutoBrowser bool
8888
hideStaleIncoming bool
8989
noCache bool
90+
systrayInterface SystrayInterface // For mocking systray operations in tests
9091
hiddenOrgs map[string]bool
9192
seenOrgs map[string]bool
9293

@@ -215,6 +216,7 @@ func main() {
215216
enableAutoBrowser: false, // Default to false for safety
216217
browserRateLimiter: NewBrowserRateLimiter(browserOpenDelay, maxBrowserOpensMinute, maxBrowserOpensDay),
217218
startTime: startTime,
219+
systrayInterface: &RealSystray{}, // Use real systray implementation
218220
seenOrgs: make(map[string]bool),
219221
hiddenOrgs: make(map[string]bool),
220222
// Deprecated fields for test compatibility

cmd/goose/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func TestSoundPlaybackDuringTransitions(t *testing.T) {
299299
enableAudioCues: true,
300300
initialLoadComplete: true, // Set to true to allow sound playback
301301
menuInitialized: true,
302-
lastMenuTitles: []string{"placeholder"}, // Initialize to prevent menu rebuilds during testing
302+
systrayInterface: &MockSystray{}, // Use mock systray to avoid Windows-specific panics
303303
}
304304

305305
tests := []struct {

cmd/goose/ui.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ func (app *App) rebuildMenu(ctx context.Context) {
388388
// Rebuild entire menu
389389

390390
// Clear all existing menu items
391-
systray.ResetMenu()
391+
app.systrayInterface.ResetMenu()
392392

393393
// Check for auth error first
394394
if app.authError != "" {

0 commit comments

Comments
 (0)