Skip to content

Commit f9df84d

Browse files
Thomas StrombergThomas Stromberg
authored andcommitted
add more tests
1 parent a6b2a6b commit f9df84d

35 files changed

+3513
-515
lines changed

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.25.1
44

55
require (
66
github.com/codeGROOVE-dev/ds9 v0.6.0
7-
github.com/codeGROOVE-dev/gh-mailto v0.0.0-20251030132316-7b86852c2928
7+
github.com/codeGROOVE-dev/gh-mailto v0.0.0-20251030182955-b6a1494332f1
88
github.com/codeGROOVE-dev/gsm v0.0.0-20251019065141-833fe2363d22
99
github.com/codeGROOVE-dev/prx v0.0.0-20251030022101-ff906928a1e4
1010
github.com/codeGROOVE-dev/retry v1.3.0
@@ -29,8 +29,6 @@ require (
2929
github.com/gorilla/websocket v1.5.3 // indirect
3030
github.com/kr/pretty v0.3.1 // indirect
3131
github.com/rogpeppe/go-internal v1.14.1 // indirect
32-
github.com/shurcooL/githubv4 v0.0.0-20240727222349-48295856cce7 // indirect
33-
github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 // indirect
3432
github.com/stretchr/testify v1.11.1 // indirect
3533
golang.org/x/crypto v0.43.0 // indirect
3634
golang.org/x/net v0.46.0 // indirect

go.sum

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ
44
github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
55
github.com/codeGROOVE-dev/ds9 v0.6.0 h1:JG7vBH17UAKaVoeQilrIvA1I0fg3iNbdUMBSDS7ixgI=
66
github.com/codeGROOVE-dev/ds9 v0.6.0/go.mod h1:0UDipxF1DADfqM5GtjefgB2u+EXdDgOKmxVvrSGLHoM=
7-
github.com/codeGROOVE-dev/gh-mailto v0.0.0-20251030132316-7b86852c2928 h1:fDiQ7GnN6tDUIrYqXKCmxcatFzZqr+Bp3aNBA0Q2AVk=
8-
github.com/codeGROOVE-dev/gh-mailto v0.0.0-20251030132316-7b86852c2928/go.mod h1:4Hr2ySB8dcpeZqZq/7UbXdEJ/5RK9coYGHvW90ZfieE=
7+
github.com/codeGROOVE-dev/gh-mailto v0.0.0-20251030182955-b6a1494332f1 h1:VB5mLo9mIgBHTMwRQicKDPz0VYy0xcvBSrtV5IZtaZc=
8+
github.com/codeGROOVE-dev/gh-mailto v0.0.0-20251030182955-b6a1494332f1/go.mod h1:HFNNMF5nOOUTC3hboPiS/03K0IhKSUGEIQ7i7nxYSI0=
99
github.com/codeGROOVE-dev/gsm v0.0.0-20251019065141-833fe2363d22 h1:gtN3rOc6YspO646BkcOxBhPjEqKUz+jl175jIqglfDg=
1010
github.com/codeGROOVE-dev/gsm v0.0.0-20251019065141-833fe2363d22/go.mod h1:KV+w19ubP32PxZPE1hOtlCpTaNpF0Bpb32w5djO8UTg=
1111
github.com/codeGROOVE-dev/prx v0.0.0-20251030022101-ff906928a1e4 h1:DSuoUwP3oyR4cHrX0cUh9c7CtYjXNIcyCmqpIwHilIU=
@@ -49,10 +49,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
4949
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
5050
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
5151
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
52-
github.com/shurcooL/githubv4 v0.0.0-20240727222349-48295856cce7 h1:cYCy18SHPKRkvclm+pWm1Lk4YrREb4IOIb/YdFO0p2M=
53-
github.com/shurcooL/githubv4 v0.0.0-20240727222349-48295856cce7/go.mod h1:zqMwyHmnN/eDOZOdiTohqIUKUrTFX62PNlu7IJdu0q8=
54-
github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 h1:17JxqqJY66GmZVHkmAsGEkcIu0oCe3AM420QDgGwZx0=
55-
github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466/go.mod h1:9dIRpgIY7hVhoqfe0/FcYp0bpInZaT7dc3BYOprrIUE=
5652
github.com/slack-go/slack v0.17.3 h1:zV5qO3Q+WJAQ/XwbGfNFrRMaJ5T/naqaonyPV/1TP4g=
5753
github.com/slack-go/slack v0.17.3/go.mod h1:X+UqOufi3LYQHDnMG1vxf0J8asC6+WllXrVrhl8/Prk=
5854
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=

pkg/bot/bot.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"time"
1313

1414
"github.com/codeGROOVE-dev/slacker/pkg/bot/cache"
15-
"github.com/codeGROOVE-dev/slacker/pkg/config"
1615
"github.com/codeGROOVE-dev/slacker/pkg/notify"
1716
"github.com/codeGROOVE-dev/slacker/pkg/usermapping"
1817
"github.com/codeGROOVE-dev/turnclient/pkg/turn"
@@ -57,7 +56,7 @@ type Coordinator struct {
5756
workspaceName string // Track workspace name for better logging
5857
slack SlackClient
5958
github GitHubClient
60-
configManager *config.Manager
59+
configManager ConfigManager
6160
notifier *notify.Manager
6261
userMapper UserMapper
6362
threadCache *ThreadCache // In-memory cache for fast lookups
@@ -84,7 +83,7 @@ func New(
8483
ctx context.Context,
8584
slackClient SlackClient,
8685
githubClient GitHubClient,
87-
configManager *config.Manager,
86+
configManager ConfigManager,
8887
notifier *notify.Manager,
8988
sprinklerURL string,
9089
stateStore StateStore,

pkg/bot/bot_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"testing"
77

88
"github.com/codeGROOVE-dev/slacker/pkg/bot/cache"
9-
"github.com/codeGROOVE-dev/slacker/pkg/config"
109
"github.com/slack-go/slack"
1110
)
1211

@@ -26,7 +25,7 @@ func TestNew(t *testing.T) {
2625
token: "test-token",
2726
}
2827

29-
configMgr := config.New()
28+
configMgr := NewMockConfig().Build()
3029
stateStore := &mockStateStore{
3130
processedEvents: make(map[string]bool),
3231
}
@@ -99,7 +98,7 @@ func TestNew_WorkspaceInfoFailure(t *testing.T) {
9998
token: "test-token",
10099
}
101100

102-
configMgr := config.New()
101+
configMgr := NewMockConfig().Build()
103102
stateStore := &mockStateStore{
104103
processedEvents: make(map[string]bool),
105104
}
@@ -144,7 +143,7 @@ func TestNew_WithGitHubClient(t *testing.T) {
144143
client: fakeGHClient,
145144
}
146145

147-
configMgr := config.New()
146+
configMgr := NewMockConfig().Build()
148147
stateStore := &mockStateStore{
149148
processedEvents: make(map[string]bool),
150149
}
@@ -169,7 +168,7 @@ func TestNew_WithGitHubClient(t *testing.T) {
169168

170169
func TestSaveThread(t *testing.T) {
171170
mockSlack := &mockSlackClient{}
172-
configMgr := config.New()
171+
configMgr := NewMockConfig().Build()
173172

174173
mockState := &mockStateStore{
175174
processedEvents: make(map[string]bool),
@@ -222,7 +221,7 @@ func TestSaveThread(t *testing.T) {
222221

223222
func TestSaveThread_PersistenceError(t *testing.T) {
224223
mockSlack := &mockSlackClient{}
225-
configMgr := config.New()
224+
configMgr := NewMockConfig().Build()
226225

227226
mockState := &mockStateStore{
228227
processedEvents: make(map[string]bool),

pkg/bot/coordinator_test_helpers.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"time"
88

99
ghmailto "github.com/codeGROOVE-dev/gh-mailto/pkg/gh-mailto"
10+
"github.com/codeGROOVE-dev/slacker/pkg/github"
1011
"github.com/codeGROOVE-dev/slacker/pkg/state"
1112
"github.com/codeGROOVE-dev/slacker/pkg/usermapping"
1213
"github.com/slack-go/slack"
@@ -431,3 +432,32 @@ type TagInfo struct {
431432
TaggedAt time.Time
432433
WorkspaceID string
433434
}
435+
436+
// notifyError is a simple error type for testing notification failures.
437+
type notifyError struct {
438+
message string
439+
}
440+
441+
func (e *notifyError) Error() string {
442+
return e.message
443+
}
444+
445+
// mockPRSearcher implements PRSearcher interface for testing polling logic.
446+
type mockPRSearcher struct {
447+
listOpenPRsFunc func(ctx context.Context, org string, updatedSinceHours int) ([]github.PRSnapshot, error)
448+
listClosedPRsFunc func(ctx context.Context, org string, updatedSinceHours int) ([]github.PRSnapshot, error)
449+
}
450+
451+
func (m *mockPRSearcher) ListOpenPRs(ctx context.Context, org string, updatedSinceHours int) ([]github.PRSnapshot, error) {
452+
if m.listOpenPRsFunc != nil {
453+
return m.listOpenPRsFunc(ctx, org, updatedSinceHours)
454+
}
455+
return nil, errors.New("mock: ListOpenPRs not configured")
456+
}
457+
458+
func (m *mockPRSearcher) ListClosedPRs(ctx context.Context, org string, updatedSinceHours int) ([]github.PRSnapshot, error) {
459+
if m.listClosedPRsFunc != nil {
460+
return m.listClosedPRsFunc(ctx, org, updatedSinceHours)
461+
}
462+
return nil, errors.New("mock: ListClosedPRs not configured")
463+
}

0 commit comments

Comments
 (0)