feat: notify on workspace creation (#15934)

This commit is contained in:
Danielle Maywood
2024-12-20 13:53:10 +00:00
committed by GitHub
parent f5d3f713c6
commit f0e81ab455
10 changed files with 291 additions and 14 deletions
@@ -92,8 +92,31 @@ func (f *FakeEnqueuer) Clear() {
f.sent = nil
}
func (f *FakeEnqueuer) Sent() []*FakeNotification {
func (f *FakeEnqueuer) Sent(matchers ...func(*FakeNotification) bool) []*FakeNotification {
f.mu.Lock()
defer f.mu.Unlock()
return append([]*FakeNotification{}, f.sent...)
sent := []*FakeNotification{}
for _, notif := range f.sent {
// Check this notification matches all given matchers
matches := true
for _, matcher := range matchers {
if !matcher(notif) {
matches = false
break
}
}
if matches {
sent = append(sent, notif)
}
}
return sent
}
func WithTemplateID(id uuid.UUID) func(*FakeNotification) bool {
return func(n *FakeNotification) bool {
return n.TemplateID == id
}
}