Skip to content

test: install goravel/slack and add Slack notification tests - #145

Open
goravel-coder wants to merge 5 commits into
masterfrom
bowen/install-slack-tests
Open

test: install goravel/slack and add Slack notification tests#145
goravel-coder wants to merge 5 commits into
masterfrom
bowen/install-slack-tests

Conversation

@goravel-coder

@goravel-coder goravel-coder commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Install and register the github.com/goravel/slack package, exposing a slack notification channel configured via SLACK_BOT_TOKEN/SLACK_CHANNEL, with the target channel read through the app config (slack.channel) so .env values are honored.
  • Add a live Slack notification test suite covering channel registration plus text and rich (attachment/field) delivery to a real workspace, skipped locally when no bot token is set; send failures now report the target channel.
  • Add package install/uninstall round-trip coverage and wire the Slack bot token and channel into feature CI via secrets.

Why

The example app previously had no Slack notification channel: facades.Notification().Channel("slack") resolved to nil and Slack delivery couldn't be demonstrated. This change installs and registers the github.com/goravel/slack package so notifications can be routed to a real Slack workspace, and adds tests proving the channel is registered, text and rich messages are delivered, and the package can be cleanly installed/uninstalled.

The target channel is read through facades.Config().GetString("slack.channel") (backed by SLACK_CHANNEL) rather than os.Getenv, so a channel set in .env is respected and the same source is used across the suite. The live-send assertions now include the channel in their error message, and feature CI passes SLACK_BOT_TOKEN/SLACK_CHANNEL through as secrets.

import (
	"github.com/goravel/framework/contracts/notification"
	slackcontracts "github.com/goravel/slack/contracts"
)

type InvoicePaid struct {
	Amount string
}

func (r *InvoicePaid) Via(notifiable notification.Notifiable) []string {
	return []string{slackcontracts.ChannelName}
}

func (r *InvoicePaid) ToSlack(notifiable notification.Notifiable) slackcontracts.Message {
	return slackcontracts.Message{
		Text: "Invoice paid: $" + r.Amount,
	}
}

// send it
facades.Notification().
	Route(slackcontracts.ChannelName, "#sales").
	NotifyNow(&notifications.InvoicePaid{Amount: "99.00"})
image

@goravel-coder
goravel-coder requested a review from a team as a code owner August 21, 2026 08:42
@hwbrzzl
hwbrzzl force-pushed the bowen/install-slack-tests branch from 5539669 to ab940e1 Compare August 21, 2026 09:23
Comment thread bootstrap/providers.go Outdated
Comment thread tests/feature/slack_test.go Outdated
Comment thread config/slack.go Outdated
opencode added 3 commits August 21, 2026 17:40
- drop redundant slack import alias in providers.go
- group third-party imports in slack_test.go
- hardcode target Slack channel to 'general' instead of SLACK_CHANNEL config
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