2014-04-17 22:57:13 +00:00
|
|
|
package notify
|
|
|
|
|
2014-10-23 05:26:14 +00:00
|
|
|
import "testing"
|
|
|
|
|
|
|
|
/*
|
|
|
|
var request = &model.Request{
|
|
|
|
Host: "http://examplehost.com",
|
|
|
|
Repo: &model.Repo{
|
|
|
|
Host: "examplegit.com",
|
|
|
|
Owner: "owner",
|
|
|
|
Name: "repo",
|
|
|
|
},
|
|
|
|
Commit: &model.Commit{
|
|
|
|
Sha: "abc",
|
|
|
|
Branch: "example",
|
|
|
|
Status: "Started",
|
|
|
|
Message: "Test Commit",
|
|
|
|
Author: "Test User",
|
|
|
|
},
|
|
|
|
User: &model.User{
|
|
|
|
Login: "TestUser",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2014-11-04 19:39:33 +00:00
|
|
|
var slackExpectedLink = "<http://examplehost.com/examplegit.com/owner/repo/example/abc|owner/repo#abc>"
|
2014-10-23 05:26:14 +00:00
|
|
|
var slackExpectedBase = slackExpectedLink + " (example) by Test User"
|
|
|
|
|
|
|
|
func Test_slackStartedMessage(t *testing.T) {
|
|
|
|
actual := (&Slack{}).getMessage(request, slackStartedMessage)
|
|
|
|
|
|
|
|
expected := "*Building* " + slackExpectedBase
|
|
|
|
|
|
|
|
if actual != expected {
|
|
|
|
t.Errorf("Invalid getStarted message for Slack. Expected %v, got %v", expected, actual)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func Test_slackSuccessMessage(t *testing.T) {
|
|
|
|
actual := (&Slack{}).getMessage(request, slackSuccessMessage)
|
|
|
|
|
|
|
|
expected := "*Success* " + slackExpectedBase
|
|
|
|
|
|
|
|
if actual != expected {
|
|
|
|
t.Errorf("Invalid getStarted message for Slack. Expected %v, got %v", expected, actual)
|
2014-04-17 22:57:13 +00:00
|
|
|
}
|
2014-10-23 05:26:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func Test_slackFailureMessage(t *testing.T) {
|
|
|
|
actual := (&Slack{}).getMessage(request, slackFailureMessage)
|
|
|
|
|
|
|
|
expected := "*Failed* " + slackExpectedBase
|
2014-04-17 22:57:13 +00:00
|
|
|
|
2014-10-23 05:26:14 +00:00
|
|
|
if actual != expected {
|
|
|
|
t.Errorf("Invalid getStarted message for Slack. Expected %v, got %v", expected, actual)
|
2014-04-17 22:57:13 +00:00
|
|
|
}
|
|
|
|
}
|