Skip to content

test: add notification channel routing tests (framework#1535) - #142

Merged
hwbrzzl merged 2 commits into
masterfrom
bowen/notification-channel-routing-tests
Aug 16, 2026
Merged

test: add notification channel routing tests (framework#1535)#142
hwbrzzl merged 2 commits into
masterfrom
bowen/notification-channel-routing-tests

Conversation

@goravel-coder

Copy link
Copy Markdown
Contributor

Summary

  • Bumps goravel/framework to the channel-routing build (framework#1535) and switches example notifications from "mail"/"database" literals to the notification.ChannelMail/notification.ChannelDatabase constants.
  • Adds a typed database route (RouteNotificationForDatabase) to the User model that takes precedence over the generic RouteNotificationFor fallback for the database channel.
  • Adds feature coverage for typed-route precedence, empty-route errors (NotificationDatabaseEmptyRoute/NotificationMailEmptyRoute), and per-connection database delivery.

Why

Framework#1535 introduced typed notification routing: a DatabaseRoutable notifiable can declare RouteNotificationForDatabase(), which wins over the generic RouteNotificationFor fallback, and delivery fails with distinct empty-route errors when no route resolves. This branch upgrades the example to the new framework build, migrates example notifications to the exported channel constants, and implements the typed route on the User model so the example stays a faithful reference for the new API.

func (r *User) RouteNotificationFor(channel string) any {
	switch channel {
	case notification.ChannelMail:
		return r.Mail
	case notification.ChannelDatabase:
		return r.RouteNotificationForDatabase()
	default:
		return nil
	}
}

// RouteNotificationForDatabase implements contracts/notification.DatabaseRoutable:
// the type-safe database delivery route, preferred over RouteNotificationFor.
func (r *User) RouteNotificationForDatabase() string {
	return strconv.FormatUint(uint64(r.ID), 10)
}

The new tests pin down the routing semantics: the typed route is preferred when it returns a value, an empty typed route falls back to RouteNotificationFor, and both empty means delivery fails with the framework's empty-route error — so example behavior matches the framework contract exactly.

@goravel-coder
goravel-coder requested a review from a team as a code owner August 16, 2026 10:23
Comment thread app/models/user.go Outdated
Comment thread app/models/user.go Outdated
@hwbrzzl
hwbrzzl merged commit 620c5d5 into master Aug 16, 2026
9 checks passed
@hwbrzzl
hwbrzzl deleted the bowen/notification-channel-routing-tests branch August 16, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants