refactor(message): update default message
This commit is contained in:
parent
861d6e1adb
commit
4d2a304048
14
plugin.go
14
plugin.go
@ -220,7 +220,7 @@ func (p Plugin) Exec() error {
|
||||
if len(p.Config.Message) > 0 {
|
||||
message = p.Config.Message
|
||||
} else {
|
||||
message = p.Message(p.Repo, p.Commit, p.Build)
|
||||
message = p.Message()
|
||||
}
|
||||
|
||||
bot, err := tgbotapi.NewBotAPI(p.Config.Token)
|
||||
@ -369,12 +369,12 @@ func (p Plugin) Send(bot *tgbotapi.BotAPI, msg tgbotapi.Chattable) error {
|
||||
}
|
||||
|
||||
// Message is plugin default message.
|
||||
func (p Plugin) Message(repo Repo, commit Commit, build Build) []string {
|
||||
func (p Plugin) Message() []string {
|
||||
return []string{fmt.Sprintf("[%s] <%s> (%s)『%s』by %s",
|
||||
build.Status,
|
||||
build.Link,
|
||||
commit.Branch,
|
||||
commit.Message,
|
||||
commit.Author,
|
||||
p.Build.Status,
|
||||
p.Build.Link,
|
||||
p.Commit.Branch,
|
||||
p.Commit.Message,
|
||||
p.Commit.Author,
|
||||
)}
|
||||
}
|
||||
|
@ -46,11 +46,35 @@ func TestDefaultMessageFormat(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
message := plugin.Message(plugin.Repo, plugin.Commit, plugin.Build)
|
||||
message := plugin.Message()
|
||||
|
||||
assert.Equal(t, []string{"[success] <https://github.com/appleboy/go-hello> (master)『update travis』by Bo-Yi Wu"}, message)
|
||||
}
|
||||
|
||||
// func TestDefaultMessageFormatFromGitHub(t *testing.T) {
|
||||
// plugin := Plugin{
|
||||
// Repo: Repo{
|
||||
// Name: "go-hello",
|
||||
// Namespace: "appleboy",
|
||||
// },
|
||||
// Commit: Commit{
|
||||
// Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
||||
// Author: "Bo-Yi Wu",
|
||||
// Branch: "master",
|
||||
// Message: "update travis",
|
||||
// },
|
||||
// Build: Build{
|
||||
// Number: 101,
|
||||
// Status: "success",
|
||||
// Link: "https://github.com/appleboy/go-hello",
|
||||
// },
|
||||
// }
|
||||
|
||||
// message := plugin.Message()
|
||||
|
||||
// assert.Equal(t, []string{"[success] <https://github.com/appleboy/go-hello> (master)『update travis』by Bo-Yi Wu"}, message)
|
||||
// }
|
||||
|
||||
func TestSendMessage(t *testing.T) {
|
||||
plugin := Plugin{
|
||||
Repo: Repo{
|
||||
|
Loading…
Reference in New Issue
Block a user